Example #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'
Example #2
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')
Example #3
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']
Example #4
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')
Example #5
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']
Example #6
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'
Example #7
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']
Example #8
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']
Example #9
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
Example #10
0
 def test_contains(self):
     cache = Memcached()
     cache.client = self.mock_memcache
     cache.client.get.return_value = False
     cache.flush()
     assert not 'test' in cache
     cache['test'] = 'test'
     cache.client.get.return_value = True
     assert 'test' in cache
Example #11
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']
Example #12
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'
Example #13
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']
Example #14
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'