示例#1
0
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')
示例#2
0
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')
示例#3
0
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)
示例#4
0
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)
示例#5
0
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)
示例#6
0
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)