Use FormCache everywhere

This commit is contained in:
richard-dds
2018-11-16 11:42:33 -05:00
parent 6177f46587
commit 5447be8b52
2 changed files with 14 additions and 20 deletions

View File

@@ -1,15 +1,21 @@
import pytest
from werkzeug.datastructures import ImmutableDict
from atst.utils.form_cache import DEFAULT_CACHE_NAME, cache_form_data, retrieve_form_data
from atst.utils.form_cache import DEFAULT_CACHE_NAME, FormCache
def test_cache_form_data(app):
@pytest.fixture
def form_cache(app):
return FormCache(app.redis)
def test_cache_form_data(app, form_cache):
data = ImmutableDict({"kessel_run": "12 parsecs"})
key = cache_form_data(app.redis, data)
key = form_cache.write(data)
assert app.redis.get("{}:{}".format(DEFAULT_CACHE_NAME, key))
def test_retrieve_form_data(app):
def test_retrieve_form_data(form_cache):
data = ImmutableDict({"class": "corellian"})
key = cache_form_data(app.redis, data)
retrieved = retrieve_form_data(app.redis, key)
key = form_cache.write(data)
retrieved = form_cache.read(key)
assert retrieved == data