Skip to content

Commit 653e2a8

Browse files
author
danameyer
committed
differentiate between scenarios where stop_on_fail is true and stop_on_fail is false. Refs #5.
1 parent d063ef4 commit 653e2a8

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

tests/unit_tests/preprocess_test.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import os
33
import unittest
44
from typing import List
5+
from unittest.mock import patch
6+
7+
from flow_preprocessor.exceptions.exceptions import ImageFetchException
58
from flow_preprocessor.preprocessing_logic.preprocess import Preprocessor
69

710

@@ -30,11 +33,33 @@ def test_preprocess_crop_false(self):
3033
asyncio.run(self.preprocessor.preprocess_xml_file_list(self.xml_files, self.in_path, self.out_path))
3134

3235
def test_preprocess_crop_true(self):
33-
asyncio.run(self.preprocessor.preprocess_xml_file_list(self.xml_files, self.in_path, self.out_path, crop=True))
36+
asyncio.run(self.preprocessor.preprocess_xml_file_list(self.xml_files,
37+
self.in_path,
38+
self.out_path,
39+
crop=True,
40+
stop_on_fail=False))
3441

3542
def test_preprocess_abbrev_true(self):
3643
asyncio.run(
37-
self.preprocessor.preprocess_xml_file_list(self.xml_files, self.in_path, self.out_path, abbrev=True))
44+
self.preprocessor.preprocess_xml_file_list(self.xml_files,
45+
self.in_path,
46+
self.out_path,
47+
abbrev=True,
48+
stop_on_fail=False))
49+
50+
def test_preprocess_with_failure_due_to_invalid_file(self):
51+
# Simulate invalid XML files that would lead to an ImageFetchException
52+
invalid_xml_files = ["invalid_file.xml"]
53+
54+
with patch(
55+
'flow_preprocessor.preprocessing_logic.preprocess.Preprocessor.preprocess_xml_file_list') as mock_preprocess:
56+
mock_preprocess.side_effect = ImageFetchException("Simulated failure during file processing.")
57+
58+
with self.assertRaises(ImageFetchException) as context:
59+
asyncio.run(self.preprocessor.preprocess_xml_file_list(
60+
invalid_xml_files, self.in_path, self.out_path, stop_on_fail=True))
61+
62+
self.assertIn("Simulated failure during file processing", str(context.exception))
3863

3964
def tearDown(self) -> None:
4065
"""

0 commit comments

Comments
 (0)