Пример #1
0
 def to_json(self):
     return types.JsonTree(
         tree=self.tree,
         status=self.status,
         reason=self.reason,
         message_of_the_day=self.message_of_the_day,
     )
Пример #2
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)
Пример #3
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')
Пример #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)