Esempio n. 1
0
def test_clear():
    cache = Cache('test', data_dir='./cache', url=db_url, type='ext:database')
    o = object()
    cache.set_value("test", o)
    assert "test" in cache
    cache.clear()
    assert "test" not in cache
Esempio n. 2
0
def test_has_key_multicache():
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    o = object()
    cache.set_value("test", o)
    assert "test" in cache
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    assert "test" in cache
Esempio n. 3
0
    def test_pylibmc_pool_sharing(self):
        from beaker.ext import memcached

        cache_1a = Cache(
            "test_1a",
            data_dir="./cache",
            memcache_module="pylibmc",
            url=mc_url,
            type="ext:memcached",
        )
        cache_1b = Cache(
            "test_1b",
            data_dir="./cache",
            memcache_module="pylibmc",
            url=mc_url,
            type="ext:memcached",
        )
        cache_2 = Cache(
            "test_2",
            data_dir="./cache",
            memcache_module="pylibmc",
            url="127.0.0.1:11212",
            type="ext:memcached",
        )

        assert cache_1a.namespace.pool is cache_1b.namespace.pool
        assert cache_1a.namespace.pool is not cache_2.namespace.pool
Esempio n. 4
0
def test_has_key_multicache():
    cache = Cache('test', data_dir='./cache', type='dbm')
    o = object()
    cache.set_value("test", o)
    assert "test" in cache
    cache = Cache('test', data_dir='./cache', type='dbm')
    assert "test" in cache
Esempio n. 5
0
def test_spaces_in_keys():
    cache = Cache("test", data_dir="./cache", url=mc_url, type="ext:memcached")
    cache.set_value("has space", 24)
    assert cache.has_key("has space")
    assert 24 == cache.get_value("has space")
    cache.set_value("hasspace", 42)
    assert cache.has_key("hasspace")
    assert 42 == cache.get_value("hasspace")
Esempio n. 6
0
def test_long_unicode_keys():
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    o = object()
    long_str = u_('Очень длинная строка, которая не влезает в сто двадцать восемь байт и поэтому не проходит ограничение в check_key, что очень прискорбно, не правда ли, друзья? Давайте же скорее исправим это досадное недоразумение!')
    cache.set_value(long_str, o)
    assert long_str in cache
    cache.remove_value(long_str)
    assert long_str not in cache
def test_unicode_keys():
    cache = Cache('test', url=db_url, type=db_type, database=db_name)
    o = object()
    cache.set_value(u'hiŏ', o)
    assert u'hiŏ' in cache
    assert u'hŏa' not in cache
    cache.remove_value(u'hiŏ')
    assert u'hiŏ' not in cache
Esempio n. 8
0
def test_spaces_in_unicode_keys():
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    o = object()
    cache.set_value(u_('hi ŏ'), o)
    assert u_('hi ŏ') in cache
    assert u_('hŏa') not in cache
    cache.remove_value(u_('hi ŏ'))
    assert u_('hi ŏ') not in cache
Esempio n. 9
0
def test_spaces_in_keys():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb')
    cache.set_value("has space", 24)
    assert cache.has_key("has space")
    assert 24 == cache.get_value("has space")
    cache.set_value("hasspace", 42)
    assert cache.has_key("hasspace")
    assert 42 == cache.get_value("hasspace")
Esempio n. 10
0
def test_unicode_keys():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb', sparse_collection=True)
    o = object()
    cache.set_value(u'hiŏ', o)
    assert u'hiŏ' in cache
    assert u'hŏa' not in cache
    cache.remove_value(u'hiŏ')
    assert u'hiŏ' not in cache
Esempio n. 11
0
def test_spaces_in_keys():
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    cache.set_value("has space", 24)
    assert cache.has_key("has space")
    assert 24 == cache.get_value("has space")
    cache.set_value("hasspace", 42)
    assert cache.has_key("hasspace")
    assert 42 == cache.get_value("hasspace")
Esempio n. 12
0
def test_unicode_keys():    
    cache = Cache('test', data_dir='./cache', type='dbm')
    o = object()
    cache.set_value(u'hiŏ', o)
    assert u'hiŏ' in cache
    assert u'hŏa' not in cache
    cache.remove_value(u'hiŏ')
    assert u'hiŏ' not in cache
Esempio n. 13
0
 def test_spaces_in_unicode_keys(self):
     cache = Cache('test', **self.CACHE_ARGS)
     o = object()
     cache.set_value(u_('hi ŏ'), o)
     assert u_('hi ŏ') in cache
     assert u_('hŏa') not in cache
     cache.remove_value(u_('hi ŏ'))
     assert u_('hi ŏ') not in cache
Esempio n. 14
0
def test_spaces_in_unicode_keys():
    cache = Cache("test", data_dir="./cache", url=mc_url, type="ext:memcached")
    o = object()
    cache.set_value(u"hi ŏ", o)
    assert u"hi ŏ" in cache
    assert u"hŏa" not in cache
    cache.remove_value(u"hi ŏ")
    assert u"hi ŏ" not in cache
Esempio n. 15
0
def test_unicode_keys():
    cache = Cache("test", data_dir="./cache", url=db_url, type="ext:database")
    o = object()
    cache.set_value(u"hiŏ", o)
    assert u"hiŏ" in cache
    assert u"hŏa" not in cache
    cache.remove_value(u"hiŏ")
    assert u"hiŏ" not in cache
Esempio n. 16
0
 def test_spaces_in_keys(self):
     cache = Cache('test', **self.CACHE_ARGS)
     cache.set_value("has space", 24)
     assert cache.has_key("has space")
     assert 24 == cache.get_value("has space")
     cache.set_value("hasspace", 42)
     assert cache.has_key("hasspace")
     assert 42 == cache.get_value("hasspace")
Esempio n. 17
0
def test_unicode_keys():
    cache = Cache('test', data_dir='./cache', url=db_url, type='ext:database')
    o = object()
    cache.set_value(u_('hiŏ'), o)
    assert u_('hiŏ') in cache
    assert u_('hŏa') not in cache
    cache.remove_value(u_('hiŏ'))
    assert u_('hiŏ') not in cache
Esempio n. 18
0
def test_has_key_multicache():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb', sparse_collection=True, skip_pickle=True)
    o = object()
    cache.set_value("test", o)
    assert "test" in cache
    assert "test" in cache
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb', sparse_collection=True, skip_pickle=True)
    assert "test" in cache
Esempio n. 19
0
def test_spaces_in_unicode_keys():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb')
    o = object()
    cache.set_value(u'hi ŏ', o)
    assert u'hi ŏ' in cache
    assert u'hŏa' not in cache
    cache.remove_value(u'hi ŏ')
    assert u'hi ŏ' not in cache
Esempio n. 20
0
def test_has_key():
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    o = object()
    cache.set_value("test", o)
    assert "test" in cache
    assert "foo" not in cache
    cache.remove_value("test")
    assert "test" not in cache
Esempio n. 21
0
def test_has_key_multicache():
    cache = Cache('test', data_dir='./cache', url=db_url, type='ext:database')
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    cache = Cache('test', data_dir='./cache', url=db_url, type='ext:database')
    assert cache.has_key("test")
    cache.remove_value('test')
Esempio n. 22
0
def test_long_unicode_keys():
    cache = Cache("test", data_dir="./cache", url=mc_url, type="ext:memcached")
    o = object()
    for i in range(0, 260):
        long_str = u"Ы" * i
        cache.set_value(long_str, o)
        assert long_str in cache
        cache.remove_value(long_str)
        assert long_str not in cache
Esempio n. 23
0
    def test_expiretime_automatic(self):
        if not self.SUPPORTS_EXPIRATION:
            self.skipTest("NamespaceManager does not support automatic expiration")

        cache = Cache("test", **self.CACHE_ARGS)
        cache.set_value("has space", 24, expiretime=1)
        assert cache.namespace.has_key("has space")
        time.sleep(1.1)
        assert not cache.namespace.has_key("has space")
Esempio n. 24
0
def test_has_key_multicache():
    cache = Cache('test', url=db_url, type=db_type, database=db_name)
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    cache = Cache('test', url=db_url, type=db_type, database=db_name)
    assert cache.has_key("test")
    cache.remove_value('test')
Esempio n. 25
0
    def test_expiretime_automatic(self):
        if not self.SUPPORTS_EXPIRATION:
            self.skipTest('NamespaceManager does not support automatic expiration')

        cache = Cache('test', **self.CACHE_ARGS)
        cache.set_value("has space", 24, expiretime=1)
        assert cache.namespace.has_key("has space")
        time.sleep(1.1)
        assert not cache.namespace.has_key("has space")
Esempio n. 26
0
 def test_client(self):
     cache = Cache('test', data_dir='./cache', url=mc_url, type="ext:memcached", 
                   protocol='binary')
     o = object()
     cache.set_value("test", o)
     assert "test" in cache
     assert "foo" not in cache
     cache.remove_value("test")
     assert "test" not in cache
Esempio n. 27
0
def test_has_key_multicache():
    cache = Cache("test", data_dir="./cache", url=db_url, type="ext:database")
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    cache = Cache("test", data_dir="./cache", url=db_url, type="ext:database")
    assert cache.has_key("test")
    cache.remove_value("test")
Esempio n. 28
0
def test_has_key():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb')
    o = object()
    cache.set_value("test", o)
    assert "test" in cache
    assert "test" in cache
    assert "foo" not in cache
    assert "foo" not in cache
    cache.remove_value("test")
    assert "test" not in cache
Esempio n. 29
0
 def test_client(self):
     cache = Cache('test', data_dir='./cache', url=uri, type="mongodb", sparse_collection=True, skip_pickle=True)
     o = object()
     cache.set_value("test", o)
     assert "test" in cache
     assert "test" in cache
     assert "foo" not in cache
     assert "foo" not in cache
     cache.remove_value("test")
     assert "test" not in cache
Esempio n. 30
0
 def test_long_unicode_keys(self):
     cache = Cache('test', **self.CACHE_ARGS)
     o = object()
     long_str = u_(
         'Очень длинная строка, которая не влезает в сто двадцать восемь байт и поэтому не проходит ограничение в check_key, что очень прискорбно, не правда ли, друзья? Давайте же скорее исправим это досадное недоразумение!'
     )
     cache.set_value(long_str, o)
     assert long_str in cache
     cache.remove_value(long_str)
     assert long_str not in cache
Esempio n. 31
0
 def setUp(self):
     self.cache = Cache(
         "testns",
         type="cassandra_cql",
         url="localhost:9042",
         keyspace=self.__keyspace,
         column_family=self.__table,
         serializer="json",
     )
     self.cache.clear()
Esempio n. 32
0
class TestRedisJson(RedisTestOverrides, CommonMethodMixin, unittest.TestCase):
    def setUp(self):
        self.cache = Cache("testns", type="ext:redis", url="redis://localhost:6379", serializer="json")
        self.cache.clear()

    @nottest
    def test_store_obj(self):
        # We can't store objects with the json serializer so skip this test from
        # the CommonMethodMixin.
        pass
Esempio n. 33
0
class TestRedisJson(RedisTestOverrides, CommonMethodMixin, unittest.TestCase):
    def setUp(self):
        self.cache = Cache("testns", type="ext:redis", url="redis://localhost:6379", serializer="json")
        self.cache.clear()

    @nottest
    def test_store_obj(self):
        # We can't store objects with the json serializer so skip this test from
        # the CommonMethodMixin.
        pass
Esempio n. 34
0
 def test_client(self):
     cache = Cache('test', data_dir='./cache', url=uri, type="mongodb")
     o = object()
     cache.set_value("test", o)
     assert "test" in cache
     assert "test" in cache
     assert "foo" not in cache
     assert "foo" not in cache
     cache.remove_value("test")
     assert "test" not in cache
Esempio n. 35
0
 def test_spaces_in_keys(self):
     cache = Cache('test', **self.CACHE_ARGS)
     cache.set_value("has space", 24)
     assert cache.has_key("has space")
     assert 24 == cache.get_value("has space")
     cache.set_value("hasspace", 42)
     assert cache.has_key("hasspace")
     assert 42 == cache.get_value("hasspace")
def test_spaces_in_keys():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb', sparse_collection=True, skip_pickle=True)
    cache.set_value("has space", 24)
    assert cache.has_key("has space")
    assert 24 == cache.get_value("has space")
    cache.set_value("hasspace", 42)
    assert cache.has_key("hasspace")
    assert 42 == cache.get_value("hasspace")
Esempio n. 37
0
def test_spaces_in_keys():
    cache = Cache("test", data_dir="./cache", url=mc_url, type="ext:memcached")
    cache.set_value("has space", 24)
    assert cache.has_key("has space")
    assert 24 == cache.get_value("has space")
    cache.set_value("hasspace", 42)
    assert cache.has_key("hasspace")
    assert 42 == cache.get_value("hasspace")
Esempio n. 38
0
def test_spaces_in_keys():
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    cache.set_value("has space", 24)
    assert cache.has_key("has space")
    assert 24 == cache.get_value("has space")
    cache.set_value("hasspace", 42)
    assert cache.has_key("hasspace")
    assert 42 == cache.get_value("hasspace")
Esempio n. 39
0
def test_spaces_in_keys():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb')
    cache.set_value("has space", 24)
    assert cache.has_key("has space")
    assert 24 == cache.get_value("has space")
    cache.set_value("hasspace", 42)
    assert cache.has_key("hasspace")
    assert 42 == cache.get_value("hasspace")
    def setUpClass(cls):
        Cache.add_backend('cassandra_cql', CassandraCqlManager)
        import cassandra
        from cassandra.cluster import Cluster

        cluster = Cluster()
        cls.__session = cluster.connect()
        try:
            cls.__create_keyspace()
        except cassandra.AlreadyExists:
            cls.__delete_keyspace()
            cls.__create_keyspace()
Esempio n. 41
0
    def setUpClass(cls):
        Cache.add_backend('cassandra_cql', CassandraCqlManager)
        import cassandra
        from cassandra.cluster import Cluster

        cluster = Cluster()
        cls.__session = cluster.connect()
        try:
            cls.__create_keyspace()
        except cassandra.AlreadyExists:
            cls.__delete_keyspace()
            cls.__create_keyspace()
Esempio n. 42
0
 def test_clear(self):
     cache = Cache("test", **self.CACHE_ARGS)
     cache.set_value("test", 20)
     cache.set_value("fred", 10)
     assert cache.has_key("test")
     assert "test" in cache
     assert cache.has_key("fred")
     cache.clear()
     assert not cache.has_key("test")
Esempio n. 43
0
 def test_clear(self):
     cache = Cache('test', **self.CACHE_ARGS)
     cache.set_value('test', 20)
     cache.set_value('fred', 10)
     assert cache.has_key('test')
     assert 'test' in cache
     assert cache.has_key('fred')
     cache.clear()
     assert not cache.has_key("test")
Esempio n. 44
0
def test_deleting_keys():
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    cache.set_value('test', 20)

    # Nuke the keys dict, it might die, who knows
    cache.namespace.mc.delete('test:keys')

    assert cache.has_key('test')

    # make sure we can still delete keys even though our keys dict got nuked
    del cache['test']

    assert not cache.has_key('test')
Esempio n. 45
0
def test_spaces_in_keys():
    cache = Cache('test',
                  data_dir='./cache',
                  url=uri,
                  type='mongodb',
                  sparse_collection=True,
                  skip_pickle=True)
    cache.set_value("has space", 24)
    assert cache.has_key("has space")
    assert 24 == cache.get_value("has space")
    cache.set_value("hasspace", 42)
    assert cache.has_key("hasspace")
    assert 42 == cache.get_value("hasspace")
Esempio n. 46
0
 def test_has_key(self):
     cache = Cache('test', **self.CACHE_ARGS)
     o = object()
     cache.set_value("test", o)
     assert cache.has_key("test")
     assert "test" in cache
     assert not cache.has_key("foo")
     assert "foo" not in cache
     cache.remove_value("test")
     assert not cache.has_key("test")
Esempio n. 47
0
def test_has_key():
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    assert not cache.has_key("foo")
    assert "foo" not in cache
    cache.remove_value("test")
    assert not cache.has_key("test")
Esempio n. 48
0
def test_clearing_cache():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb_gridfs')
    cache.set_value('test', 20)
    cache.set_value('fred', 10)
    assert cache.has_key('test')
    assert 'test' in cache
    assert cache.has_key('fred')

    cache.clear()
    assert not cache.has_key('test')
Esempio n. 49
0
def test_has_key():
    cache = Cache("test", data_dir="./cache", type="dbm")
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    assert not cache.has_key("foo")
    assert "foo" not in cache
    cache.remove_value("test")
    assert not cache.has_key("test")
Esempio n. 50
0
 def test_client(self):
     cache = Cache('test', data_dir='./cache', url=uri, type="mongodb")
     o = object()
     cache.set_value("test", o)
     assert cache.has_key("test")
     assert "test" in cache
     assert not cache.has_key("foo")
     assert "foo" not in cache
     cache.remove_value("test")
     assert not cache.has_key("test")
Esempio n. 51
0
def test_has_key():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb_gridfs')
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    assert not cache.has_key("foo")
    assert "foo" not in cache
    cache.remove_value("test")
    assert not cache.has_key("test")
Esempio n. 52
0
def test_clear():
    cache = Cache('test', url=db_url, type=db_type, database=db_name)
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    cache.clear()
    assert not cache.has_key("test")
Esempio n. 53
0
def test_clear():
    cache = Cache('test', data_dir='./cache', url=db_url, type='ext:database')
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    cache.clear()
    assert not cache.has_key("test")
Esempio n. 54
0
def test_clear():
    cache = Cache("test", data_dir="./cache", url=db_url, type="ext:database")
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    cache.clear()
    assert not cache.has_key("test")
Esempio n. 55
0
class CassandraCqlJsonSetup(object):
    __keyspace = "test_ks"
    __table = "test_table"

    def setUp(self):
        self.cache = Cache(
            "testns",
            type="cassandra_cql",
            url="localhost:9042",
            keyspace=self.__keyspace,
            column_family=self.__table,
            serializer="json",
        )
        self.cache.clear()
Esempio n. 56
0
 def test_has_key_multicache(self):
     cache = Cache('test', **self.CACHE_ARGS)
     o = object()
     cache.set_value("test", o)
     assert cache.has_key("test")
     assert "test" in cache
     cache = Cache('test', **self.CACHE_ARGS)
     assert cache.has_key("test")
Esempio n. 57
0
def test_has_key_multicache():
    cache = Cache("test", data_dir="./cache", url=mc_url, type="ext:memcached")
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    cache = Cache("test", data_dir="./cache", url=mc_url, type="ext:memcached")
    assert cache.has_key("test")
Esempio n. 58
0
def test_has_key_multicache():
    cache = Cache("test", data_dir="./cache", type="dbm")
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    cache = Cache("test", data_dir="./cache", type="dbm")
    assert cache.has_key("test")
Esempio n. 59
0
def test_has_key_multicache():
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb')
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    cache = Cache('test', data_dir='./cache', url=uri, type='mongodb')
    assert cache.has_key("test")
Esempio n. 60
0
def test_has_key_multicache():
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    o = object()
    cache.set_value("test", o)
    assert cache.has_key("test")
    assert "test" in cache
    cache = Cache('test', data_dir='./cache', url=mc_url, type='ext:memcached')
    assert cache.has_key("test")