@@ -60,9 +60,13 @@ def tearDown(self) -> None:
6060 GenericTearDown (s3_client , firehose_client , kinesis_client )
6161
6262 @staticmethod
63- def upload_source_files (source_file_content ): # pylint: disable=dangerous-default-value
64- """Uploads a test file with the TEST_FILE_KEY (RSV EMIS file) the given file content to the source bucket"""
65- s3_client .put_object (Bucket = BucketNames .SOURCE , Key = mock_rsv_emis_file .file_key , Body = source_file_content )
63+ def upload_source_files (
64+ source_file_content : str ,
65+ file_key : str = mock_rsv_emis_file .file_key
66+ ):
67+ """Uploads a test file with the TEST_FILE_KEY (RSV EMIS file as default) and the given file content to the
68+ source bucket"""
69+ s3_client .put_object (Bucket = BucketNames .SOURCE , Key = file_key , Body = source_file_content )
6670
6771 @staticmethod
6872 def get_shard_iterator ():
@@ -96,7 +100,7 @@ def make_inf_ack_assertions(self, file_details: FileDetails, passed_validation:
96100
97101 self .assertEqual (actual_rows , [InfAckFileRows .HEADERS , expected_row ])
98102
99- def make_kinesis_assertions (self , test_cases ):
103+ def make_kinesis_assertions (self , test_cases , file_details : FileDetails = mock_rsv_emis_file ):
100104 """
101105 The input is a list of test_case tuples where each tuple is structured as
102106 (test_name, index, expected_kinesis_data_ignoring_fhir_json, expect_success).
@@ -122,7 +126,7 @@ def make_kinesis_assertions(self, test_cases):
122126 with self .subTest (test_name ):
123127
124128 kinesis_record = kinesis_records [index ]
125- self .assertEqual (kinesis_record ["PartitionKey" ], mock_rsv_emis_file .queue_name )
129+ self .assertEqual (kinesis_record ["PartitionKey" ], file_details .queue_name )
126130 self .assertEqual (kinesis_record ["SequenceNumber" ], f"{ index + 1 } " )
127131
128132 # Ensure that arrival times are sequential
@@ -132,11 +136,11 @@ def make_kinesis_assertions(self, test_cases):
132136
133137 kinesis_data = json .loads (kinesis_record ["Data" ].decode ("utf-8" ), parse_float = Decimal )
134138 expected_kinesis_data = {
135- "row_id" : f"{ mock_rsv_emis_file .message_id } ^{ index + 1 } " ,
136- "file_key" : mock_rsv_emis_file .file_key ,
137- "supplier" : mock_rsv_emis_file .supplier ,
138- "vax_type" : mock_rsv_emis_file .vaccine_type ,
139- "created_at_formatted_string" : mock_rsv_emis_file .created_at_formatted_string ,
139+ "row_id" : f"{ file_details .message_id } ^{ index + 1 } " ,
140+ "file_key" : file_details .file_key ,
141+ "supplier" : file_details .supplier ,
142+ "vax_type" : file_details .vaccine_type ,
143+ "created_at_formatted_string" : file_details .created_at_formatted_string ,
140144 ** expected_kinesis_data ,
141145 }
142146 if expect_success and "fhir_json" not in expected_kinesis_data :
@@ -370,7 +374,7 @@ def test_e2e_successfully_processes_windows_1252_encoded_file_contents(self):
370374
371375 main (mock_rsv_emis_file .event_full_permissions )
372376
373- # Assertion case tuples are stuctured as
377+ # Assertion case tuples are structured as
374378 # (test_name, index, expected_kinesis_data_ignoring_fhir_json,expect_success)
375379 assertion_cases = [
376380 (
@@ -387,6 +391,34 @@ def test_e2e_successfully_processes_windows_1252_encoded_file_contents(self):
387391 mock_rsv_emis_file .file_key
388392 )
389393
394+ @patch ("utils_for_recordprocessor.is_utf8" )
395+ def test_e2e_skips_encoding_check_for_internal_suppliers (self , mock_utf_checker ):
396+ """
397+ VED-754 tests the handler successfully processes the file and skips the encoding check when the supplier is
398+ internal e.g. DPS. This is because we know they will be using the desired utf-8 encoding and avoids the extra
399+ processing time to validate the encoding. They will also be providing very large batch files so skipping this is
400+ very important.
401+ """
402+ self .upload_source_files (ValidMockFileContent .with_new_dps_record , MockFileDetails .dps_flu .file_key )
403+
404+ main (MockFileDetails .dps_flu .event_full_permissions )
405+
406+ # Assertion case tuples are structured as
407+ # (test_name, index, expected_kinesis_data_ignoring_fhir_json,expect_success)
408+ assertion_cases = [
409+ (
410+ "CREATE success" ,
411+ 0 ,
412+ {"operation_requested" : "CREATE" , "local_id" : "DPS_ID_1234^DPS_SYSTEM" },
413+ True ,
414+ )
415+ ]
416+ self .make_inf_ack_assertions (file_details = MockFileDetails .dps_flu , passed_validation = True )
417+ self .mock_util_logger .info .assert_not_called ()
418+ mock_utf_checker .assert_not_called ()
419+ self .make_kinesis_assertions (assertion_cases , file_details = MockFileDetails .dps_flu )
420+ self .mock_util_logger .info .assert_not_called ()
421+
390422
391423if __name__ == "__main__" :
392424 unittest .main ()
0 commit comments