@@ -161,32 +161,30 @@ def test_handler_with_empty_event(self):
161161 def test_handler_multi_record (self ):
162162 mock_event = {'Records' : [self .s3_vaccine , self .s3_supplier ]}
163163
164- with patch .object (self .mock_get_s3_records ,
165- "return_value" ,
166- [S3EventRecord (self .s3_vaccine ), S3EventRecord (self .s3_supplier )]):
167- # repatch mock_record_processor
168- with patch ("redis_sync.process_record" ) as mock_record_processor :
169- # Mock the return value for each record
170- mock_record_processor .side_effect = [
171- {'status' : 'success' , 'message' : 'Processed successfully' ,
172- 'file_key' : RedisCacheKey .DISEASE_MAPPING_FILE_KEY },
173- {'status' : 'success' , 'message' : 'Processed successfully' ,
174- 'file_key' : RedisCacheKey .PERMISSIONS_CONFIG_FILE_KEY }
175- ]
176-
177- handler (mock_event , None )
178-
179- # Get put_record arguments
180- args , kwargs = self .mock_firehose_client .put_record .call_args
181- record = kwargs .get ("Record" ) or args [1 ]
182- data_bytes = record ["Data" ]
183- log_json = data_bytes .decode ("utf-8" )
184- log_dict = json .loads (log_json )
185- # check expected content
186- event = log_dict ["event" ]
187- self .assertIn ("function_name" , event )
188- self .assertEqual (event ["function_name" ], "redis_sync_handler" )
189- self .assertEqual (event ["status" ], "success" )
164+ self .mock_get_s3_records .return_value = [
165+ S3EventRecord (self .s3_vaccine ), S3EventRecord (self .s3_supplier )]
166+
167+ # Mock the return value for each record
168+ self .mock_record_processor .side_effect = [
169+ {'status' : 'success' , 'message' : 'Processed successfully' ,
170+ 'file_key' : RedisCacheKey .DISEASE_MAPPING_FILE_KEY },
171+ {'status' : 'success' , 'message' : 'Processed successfully' ,
172+ 'file_key' : RedisCacheKey .PERMISSIONS_CONFIG_FILE_KEY }
173+ ]
174+
175+ handler (mock_event , None )
176+
177+ # Get put_record arguments
178+ args , kwargs = self .mock_firehose_client .put_record .call_args
179+ record = kwargs .get ("Record" ) or args [1 ]
180+ data_bytes = record ["Data" ]
181+ log_json = data_bytes .decode ("utf-8" )
182+ log_dict = json .loads (log_json )
183+ # check expected content
184+ event = log_dict ["event" ]
185+ self .assertIn ("function_name" , event )
186+ self .assertEqual (event ["function_name" ], "redis_sync_handler" )
187+ self .assertEqual (event ["status" ], "success" )
190188
191189 # test to check that event_read is called when "read" key is passed in the event
192190 def test_handler_read_event (self ):
0 commit comments