示例#1
0
class BaseRedisTest(BaseTest):
    fixtures = ['dolphin_base_flags.json']
    def __init__(self, *args, **kwargs):
        test_db = settings.DOLPHIN_BACKEND.get('TESTDB', 'featureflag_test')
        self.backend = RedisBackend(DATABASE=test_db)
        super(BaseRedisTest, self).__init__(*args, **kwargs)

    def setUp(self):
        LocalStoreMiddleware().clear()
        self.oldbackend = flipper.backend
        flipper.backend = self.backend
        super(BaseRedisTest, self).setUp()

    def tearDown(self):
        flipper.backend = self.oldbackend
        LocalStoreMiddleware().clear()
        super(BaseRedisTest, self).tearDown()

    def _get_redis(self):
        return self.backend._get_backend()

    def test_redis_is_active(self):
        r = self._get_redis()
        r.set('asdf', 'Test')
        self.assertEquals(r.get('asdf'), 'Test')


    def _fixture_setup(self):
        load_redis_fixtures(self.fixtures, self.backend)
        super(BaseRedisTest, self)._fixture_setup()

    def _fixture_teardown(self):
        self._get_redis().flushdb()
        super(BaseRedisTest, self)._fixture_teardown()
示例#2
0
 def __init__(self, *args, **kwargs):
     test_db = settings.DOLPHIN_BACKEND.get('TESTDB', 'featureflag_test')
     self.backend = RedisBackend(DATABASE=test_db)
     super(BaseRedisTest, self).__init__(*args, **kwargs)