def test_get_tree_cached(app, client): """Getting /treestatus/trees/tree1 when that tree is cached results in a read from the cache""" with app.app_context(): tree = types.JsonTree(tree='tree1', status='o', reason='r', message_of_the_day='motd') treestatus.tree_cache_set(u'tree1', tree) resp = client.get('/treestatus/trees/tree1') eq_(json.loads(resp.data)['result']['status'], 'o')
def test_memcache_functions(app): """The (private) memcached functions correctly get, set, and invalidate a cached item using a mock cache""" with app.app_context(): tree = types.JsonTree(tree='t', status='o', reason='r', message_of_the_day='motd') eq_(treestatus.tree_cache_get(u't'), None) treestatus.tree_cache_set(u't', tree) eq_(treestatus.tree_cache_get(u't').status, 'o') treestatus.tree_cache_invalidate(u't') eq_(treestatus.tree_cache_get(u't'), None)
def test_memcache_no_config(app): """With no cache configured, the (private) memcached functions do nothing""" with app.app_context(): # always misses eq_(treestatus.tree_cache_get(u't'), None) # always succeed eq_(treestatus.tree_cache_set(u't', types.JsonTree()), None) eq_(treestatus.tree_cache_invalidate(u't'), None)