@@ -8,8 +8,6 @@ class TestClients(unittest.TestCase):
88
99 BUCKET_NAME = "default-bucket"
1010 AWS_REGION = "eu-west-2"
11- REDIS_HOST = "mock-redis-host"
12- REDIS_PORT = 6379
1311
1412 def setUp (self ):
1513 self .boto3_client_patch = patch ("boto3.client" )
@@ -23,14 +21,8 @@ def setUp(self):
2321 self .mock_getenv .side_effect = lambda key , default = None : {
2422 "CONFIG_BUCKET_NAME" : self .BUCKET_NAME ,
2523 "AWS_REGION" : self .AWS_REGION ,
26- "REDIS_HOST" : self .REDIS_HOST ,
27- "REDIS_PORT" : self .REDIS_PORT
2824 }.get (key , default )
2925
30- self .redis_patch = patch ("redis.StrictRedis" )
31- self .mock_redis = self .redis_patch .start ()
32-
33- self .mock_redis .return_value = self .mock_redis
3426 self .mock_boto3_client .return_value = self .mock_boto3_client
3527 self .mock_boto3_client .return_value .send_message = {}
3628
@@ -42,8 +34,6 @@ def test_os_environ(self):
4234 importlib .reload (clients )
4335 self .assertEqual (clients .CONFIG_BUCKET_NAME , self .BUCKET_NAME )
4436 self .assertEqual (clients .REGION_NAME , self .AWS_REGION )
45- self .assertEqual (clients .REDIS_HOST , self .REDIS_HOST )
46- self .assertEqual (clients .REDIS_PORT , self .REDIS_PORT )
4737
4838 def test_boto3_client (self ):
4939 ''' Test boto3 client is created with correct parameters '''
@@ -55,11 +45,6 @@ def test_firehose_client(self):
5545 importlib .reload (clients )
5646 self .mock_boto3_client .assert_any_call ("firehose" , region_name = self .AWS_REGION )
5747
58- def test_redis_client (self ):
59- ''' Test redis client is not initialized on import '''
60- importlib .reload (clients )
61- self .mock_redis .assert_not_called ()
62-
6348 def test_logging_setup (self ):
6449 ''' Test logging is set up correctly '''
6550 importlib .reload (clients )
@@ -70,15 +55,6 @@ def test_logging_configuration(self):
7055 importlib .reload (clients )
7156 clients .logger .setLevel .assert_called_once_with ("INFO" )
7257
73- def test_redis_client_initialization (self ):
74- ''' Test redis client is initialized exactly once even with multiple invocations'''
75- importlib .reload (clients )
76- clients .get_redis_client ()
77- clients .get_redis_client ()
78- self .mock_redis .assert_called_once_with (host = self .REDIS_HOST , port = self .REDIS_PORT , decode_responses = True )
79- self .assertTrue (hasattr (clients , 'redis_client' ))
80- self .assertIsInstance (clients .redis_client , self .mock_redis .return_value .__class__ )
81-
8258 def test_logging_initialization (self ):
8359 ''' Test logging initialization '''
8460 importlib .reload (clients )
0 commit comments