Beispiel #1
0
 def test_set(self):
     cache = Memcached()
     cache.client = self.mock_memcache
     cache.client.get.return_value = 'test'
     cache.flush()
     cache['test'] = 'test'
     assert cache['test'] == 'test'
Beispiel #2
0
 def test_flush(self):
     cache = Memcached()
     cache.client = self.mock_memcache
     cache.flush()
     cache.client.get.return_value = None
     cache['test'] = 'test'
     assert cache.flush()
     assert not cache['test']
Beispiel #3
0
 def test_contains(self):
     cache = Memcached()
     cache.client = self.mock_memcache
     cache.client.get.return_value = False
     cache.flush()
     assert 'test' not in cache
     cache['test'] = 'test'
     cache.client.get.return_value = True
     assert 'test' in cache
Beispiel #4
0
 def test_delete(self):
     cache = Memcached()
     cache.client = self.mock_memcache
     cache.flush()
     cache.client.get.return_value = 'test'
     cache['test'] = 'test'
     assert cache['test'] == 'test'
     del cache['test']
     cache.client.get.return_value = None
     assert not cache['test']
Beispiel #5
0
 def test_expired(self):
     cache = Memcached()
     cache.client = self.mock_memcache
     cache.flush()
     cache.set('test', 'value', -1)
     cache.client.get.return_value = None
     assert cache.expired('test')
Beispiel #6
0
 def test_set_expired(self):
     cache = Memcached()
     cache.client = self.mock_memcache
     cache.client.get.return_value = None
     cache.flush()
     cache.set('expired', 'value', -1)
     assert not cache['expired']
Beispiel #7
0
 def test_get(self):
     cache = Memcached()
     cache.client = self.mock_memcache
     cache.flush()
     cache['test'] = 'test'
     cache.client.get.return_value = 'test'
     assert cache['test'] == 'test'
     assert cache.get('test') == 'test'
     cache.client.get.return_value = 'blah'
     assert cache.get('invalid', 'blah') == 'blah'
Beispiel #8
0
 def test_close(self):
     cache = Memcached()
     cache.client = self.mock_memcache
     assert cache.close()
Beispiel #9
0
 def test_open(self):
     with raises(ImportError):
         cache = Memcached()
         cache.open()
Beispiel #10
0
 def test_open(self):
     cache = Memcached()
     cache.open()