for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import hug
from hug_store_redis import RedisStore
import pytest
import time
import uuid
def test_store(connection):
store = RedisStore(connection, namespace='test')
key = str(uuid.uuid4())
data = {'important': True}
# Key doesn't exist
assert not store.exists(key)
# Create
store.set(key, data)
assert store.exists(key)
# Read
assert store.get(key) == data
# Update
data['important'] = False
# Delete
store.delete(key)
def test_get_unknown_key(connection):
with pytest.raises(hug.exceptions.StoreKeyNotFound):
store.get('this-does-not-exist')
def test_expiration(connection):
store = RedisStore(connection, namespace='test', expiration=1)
store.set(key, True)
time.sleep(1)