Skip to content

Commit 8aea5cd

Browse files
committed
Added test for failed processing
1 parent 8ed1dee commit 8aea5cd

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/services/test_clem_process_raw_tiffs_service.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,45 @@ def test_tiff_to_stack_service_validation_failed(
261261

262262
# Check that the message was nacked with the expected parameters
263263
offline_transport.nack.assert_called_once_with(header)
264+
265+
266+
@mock.patch("cryoemservices.services.clem_process_raw_tiffs.convert_tiff_to_stack")
267+
def test_tiff_to_stack_service_processing_failed(
268+
mock_convert,
269+
tiff_files: list[Path],
270+
metadata: Path,
271+
raw_dir: Path,
272+
offline_transport: OfflineTransport,
273+
):
274+
"""
275+
Sends a test message to the TIFF processing service, which should execute the
276+
function with the parameters present in the message, then send messages with
277+
the expected outputs back to Murfey.
278+
"""
279+
280+
# Set up the parameters
281+
header = {
282+
"message-id": mock.sentinel,
283+
"subscription": mock.sentinel,
284+
}
285+
tiff_to_stack_test_message = {
286+
"tiff_list": None,
287+
"tiff_file": str(tiff_files[0]),
288+
"root_folder": raw_dir.stem,
289+
"metadata": str(metadata),
290+
}
291+
292+
# Set up expected mock values
293+
mock_convert.return_value = None
294+
295+
# Set up and run the service
296+
service = TIFFToStackService(environment={"queue": ""}, transport=offline_transport)
297+
service.initializing()
298+
service.call_process_raw_tiffs(
299+
None,
300+
header=header,
301+
message=tiff_to_stack_test_message,
302+
)
303+
304+
# Check that the message was nacked with the expected parameters
305+
offline_transport.nack.assert_called_once_with(header)

0 commit comments

Comments
 (0)