Ejemplo n.º 1
0
 def setUp(self):
     self.coordinates = [300, 500, -100]
     self.test_coordinates = [600, 400, 0]
     self.r = fakeredis.FakeStrictRedis()
     self.db = DB()
Ejemplo n.º 2
0
 def _clear_redis(self):
     fakeredis.FakeStrictRedis().flushall()
Ejemplo n.º 3
0
 def setUp(self):
     self.redis = fakeredis.FakeStrictRedis()
     self.breaker_kwargs = {
         'state_storage': CircuitRedisStorage('closed', self.redis)
     }
     self.breaker = CircuitBreaker(**self.breaker_kwargs)
Ejemplo n.º 4
0
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')
Ejemplo n.º 5
0
 def setUp(self):
     self.redis = fakeredis.FakeStrictRedis()
     self.client_id = 381