def setUp(self): self.coordinates = [300, 500, -100] self.test_coordinates = [600, 400, 0] self.r = fakeredis.FakeStrictRedis() self.db = DB()
def _clear_redis(self): fakeredis.FakeStrictRedis().flushall()
def setUp(self): self.redis = fakeredis.FakeStrictRedis() self.breaker_kwargs = { 'state_storage': CircuitRedisStorage('closed', self.redis) } self.breaker = CircuitBreaker(**self.breaker_kwargs)
import os from unittest import TestCase from unittest.mock import patch import fakeredis import mock from marvel.decorator import cached r = fakeredis.FakeStrictRedis() class Foo(object): @cached def method1(self, param1): return 'Method1-%s' % param1 @cached def method2(self, param1, param2=1): return 'Method2-%s-%s' % (param1, param2) @patch('marvel.decorator.r', r) class TestCached(TestCase): @mock.patch.dict(os.environ, {"TC_ENABLE_CACHE_L2": "True"}) def test_method1(self): result = Foo().method1(54321) assert 'Method1-54321' == result assert '"Method1-54321"' == r.get('TC:CACHE:Foo.method1:54321').decode( 'utf-8')
def setUp(self): self.redis = fakeredis.FakeStrictRedis() self.client_id = 381