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'
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')
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']
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']
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
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
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']
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'