Skip to content

Commit 327c76c

Browse files
committed
Fixed unit test cases
1 parent 99c9abe commit 327c76c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/unit_tests/test_validation.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def test_validate_invalid_file(self, mock_download_file, mock_clean_up):
7575

7676
# Assert that validation is marked as valid
7777
self.assertFalse(result.is_valid)
78-
self.assertIn('Validation error', result.validation_message)
78+
self.assertIn('Validation error', ' '.join(result.validation_message))
79+
7980

8081
# Ensure clean_up is called twice (once for the file, once for the folder)
8182
self.assertEqual(mock_clean_up.call_count, 2)
@@ -100,6 +101,23 @@ def test_validate_invalid_zip(self, mock_clean_up, mock_osw_validation):
100101
# Ensure clean_up is called twice (once for the file, once for the folder)
101102
self.assertEqual(mock_clean_up.call_count, 1)
102103

104+
@patch('src.validation.Validation.download_single_file')
105+
def test_validate_unknown_file_format(self, mock_download_file):
106+
"""Test validation failure for unknown file format."""
107+
108+
# Mock the file path with a non-zip extension to trigger the else block
109+
self.validation.file_relative_path = 'invalid_file.txt'
110+
111+
# Mock download to not affect the actual download method
112+
mock_download_file.return_value = '/path/to/invalid_file.txt'
113+
114+
# Act
115+
result = self.validation.validate(max_errors=10)
116+
117+
# Assert that the validation failed due to unknown file format
118+
self.assertFalse(result.is_valid)
119+
self.assertEqual(result.validation_message, 'Failed to validate because unknown file format')
120+
103121
@patch('src.validation.Validation.download_single_file', return_value=f'{SAVED_FILE_PATH}/{SUCCESS_FILE_NAME}')
104122
@patch('gc.collect')
105123
@patch('shutil.rmtree')

0 commit comments

Comments
 (0)