@@ -29,6 +29,7 @@ def setUp(self):
2929 self .valid_zones_file = os .path .join (ASSETS_PATH , 'UW.zones.valid.zip' )
3030 self .invalid_zones_file = os .path .join (ASSETS_PATH , 'UW.zones.invalid.zip' )
3131 self .valid_osw_file = os .path .join (ASSETS_PATH , 'wa.bellevue.zip' )
32+ self .invalid_v_id_file = os .path .join (ASSETS_PATH , '4151.zip' )
3233 self .schema_file_path = SCHEMA_FILE_PATH
3334 self .invalid_schema_file_path = INVALID_SCHEMA_FILE_PATH
3435
@@ -45,7 +46,6 @@ def test_valid_zipfile_with_schema(self):
4546 self .assertIsNone (result .errors )
4647
4748 def test_valid_zipfile_with_invalid_schema (self ):
48-
4949 validation = OSWValidation (zipfile_path = self .valid_zipfile , schema_file_path = self .invalid_schema_file_path )
5050 result = validation .validate ()
5151 self .assertTrue (len (result .errors ) > 0 )
@@ -95,7 +95,7 @@ def test_invalid_zipfile_should_specific_errors_counts(self):
9595
9696 def test_invalid_zipfile_with_invalid_schema (self ):
9797 validation = OSWValidation (zipfile_path = self .invalid_zipfile ,
98- schema_file_path = self .invalid_schema_file_path )
98+ schema_file_path = self .invalid_schema_file_path )
9999 result = validation .validate ()
100100 self .assertTrue (len (result .errors ) > 0 )
101101
@@ -160,7 +160,8 @@ def test_external_extension_file_inside_zipfile(self):
160160 self .assertIsNone (result .errors )
161161
162162 def test_external_extension_file_inside_zipfile_with_schema (self ):
163- validation = OSWValidation (zipfile_path = self .external_extension_file_zipfile , schema_file_path = self .schema_file_path )
163+ validation = OSWValidation (zipfile_path = self .external_extension_file_zipfile ,
164+ schema_file_path = self .schema_file_path )
164165 result = validation .validate ()
165166 self .assertTrue (result .is_valid )
166167 self .assertIsNone (result .errors )
@@ -226,6 +227,29 @@ def test_invalid_zones_file(self):
226227 self .assertFalse (result .is_valid )
227228 self .assertIsNotNone (result .errors )
228229
230+ def test_unmatched_ids_limited_to_20 (self ):
231+ validation = OSWValidation (zipfile_path = self .invalid_v_id_file )
232+ result = validation .validate ()
233+
234+ # Ensure validation fails
235+ self .assertFalse (result .is_valid , 'Validation should fail, but it passed.' )
236+ self .assertTrue (result .errors , 'Validation should produce errors, but it returned none.' )
237+
238+ # Try to find the unmatched ID error message
239+ error_message = next ((err for err in result .errors if 'unmatched' in err .lower ()), None )
240+
241+ # Ensure the error message exists
242+ self .assertIsNotNone (error_message , 'Expected error message for unmatched IDs not found.' )
243+
244+ # Extract the displayed IDs from the message
245+ extracted_ids = error_message .split (':' )[- 1 ].strip ().split (', ' )
246+
247+ # Ensure only 20 IDs are displayed
248+ self .assertLessEqual (len (extracted_ids ), 20 , 'More than 20 unmatched IDs displayed in the error message.' )
249+
250+ # Ensure the total count is mentioned
251+ self .assertIn ('Showing 20 out of' , error_message )
252+
229253
230254if __name__ == '__main__' :
231255 unittest .main ()
0 commit comments