예제 #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
예제 #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
예제 #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
예제 #4
0
파일: test_cache.py 프로젝트: lecram/beaker
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
예제 #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")
예제 #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
예제 #7
0
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
예제 #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
예제 #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")
예제 #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
예제 #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")
예제 #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
예제 #13
0
파일: base.py 프로젝트: ardeois/beaker
 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
예제 #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
예제 #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
예제 #16
0
파일: base.py 프로젝트: xiaohanghang/beaker
 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")
예제 #17
0
파일: test_database.py 프로젝트: 01-/beaker
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
예제 #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
예제 #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
예제 #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
예제 #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')
예제 #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
예제 #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")
예제 #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')
예제 #25
0
파일: base.py 프로젝트: ardeois/beaker
    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")
예제 #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
예제 #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")
예제 #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
예제 #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
예제 #30
0
파일: base.py 프로젝트: ardeois/beaker
 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
예제 #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()
예제 #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
예제 #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
예제 #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
예제 #35
0
파일: base.py 프로젝트: ardeois/beaker
 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")
예제 #36
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")
예제 #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")
예제 #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")
예제 #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()
예제 #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()
예제 #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")
예제 #43
0
파일: base.py 프로젝트: xiaohanghang/beaker
 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")
예제 #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')
예제 #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")
예제 #46
0
파일: base.py 프로젝트: xiaohanghang/beaker
 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")
예제 #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")
예제 #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')
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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()
예제 #56
0
파일: base.py 프로젝트: xiaohanghang/beaker
 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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")