@@ -56,13 +56,9 @@ def test_firehose_client(self):
5656 self .mock_boto3_client .assert_any_call ("firehose" , region_name = self .AWS_REGION )
5757
5858 def test_redis_client (self ):
59- ''' Test redis client is created with correct parameters '''
59+ ''' Test redis client is not initialized on import '''
6060 importlib .reload (clients )
61- self .mock_redis .assert_called_once_with (
62- host = self .REDIS_HOST ,
63- port = self .REDIS_PORT ,
64- decode_responses = True
65- )
61+ self .mock_redis .assert_not_called ()
6662
6763 def test_logging_setup (self ):
6864 ''' Test logging is set up correctly '''
@@ -75,8 +71,10 @@ def test_logging_configuration(self):
7571 clients .logger .setLevel .assert_called_once_with ("INFO" )
7672
7773 def test_redis_client_initialization (self ):
78- ''' Test redis client initialization '''
74+ ''' Test redis client is initialized exactly once even with multiple invocations '''
7975 importlib .reload (clients )
76+ clients .get_redis_client ()
77+ clients .get_redis_client ()
8078 self .mock_redis .assert_called_once_with (host = self .REDIS_HOST , port = self .REDIS_PORT , decode_responses = True )
8179 self .assertTrue (hasattr (clients , 'redis_client' ))
8280 self .assertIsInstance (clients .redis_client , self .mock_redis .return_value .__class__ )
0 commit comments