"""Test Redis connector.""" from unittest.mock import patch from tests.fixtures import fixture_config # To hold the patched cache module redis = None def setup_module(module): """Patch the config module with a fixture.""" # Mock the config module required by the cache module module.patched_config = patch.dict( 'sys.modules', {'config': fixture_config}) module.patched_config.start() # Set a patched cache module with the config above # because the cache module imports config from shared.connectors import redis as patched_redis global redis redis = patched_redis def teardown_module(module): """Stop patching.""" module.patched_config.stop() def test_create_redis_client(): """Test that the redis client used for tests is FakeRedis.""" assert redis.config == fixture_config assert type(redis.redis_client).__name__ == 'FakeStrictRedis'