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
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
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
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
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")
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
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
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 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
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")
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
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
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
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
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_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
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
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
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
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')
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
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")
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')
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")
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
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")
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
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
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
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()
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
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
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")
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()
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")
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")
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')
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")
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")
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')
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")
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")
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")
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")
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")
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")
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()
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")
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")
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")
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")
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")