Update unit tests for new cancel behaviour
This commit is contained in:
parent
26a2e1a582
commit
d25ebabc77
2 changed files with 16 additions and 8 deletions
|
|
@ -351,10 +351,16 @@ class SmartScanThing(OFMThing):
|
||||||
finally:
|
finally:
|
||||||
# Save some final details but not set to the base model until after
|
# Save some final details but not set to the base model until after
|
||||||
# resetting valued and unlocking just in case somehow pydantic errors.
|
# resetting valued and unlocking just in case somehow pydantic errors.
|
||||||
if self._scan_data is not None:
|
|
||||||
final_image_count = self._scan_data.image_count
|
final_image_count = (
|
||||||
if self._preview_stitcher is not None:
|
self._scan_data.image_count if self._scan_data is not None else None
|
||||||
last_timestamp = self.latest_preview_stitch_time
|
)
|
||||||
|
last_timestamp = (
|
||||||
|
self.latest_preview_stitch_time
|
||||||
|
if self._preview_stitcher is not None
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
|
||||||
# However the scan finishes, unset all variables and release lock
|
# However the scan finishes, unset all variables and release lock
|
||||||
self._ongoing_scan = None
|
self._ongoing_scan = None
|
||||||
self._scan_data = None
|
self._scan_data = None
|
||||||
|
|
@ -364,8 +370,10 @@ class SmartScanThing(OFMThing):
|
||||||
|
|
||||||
# Set the final details so they persist until the next scan
|
# Set the final details so they persist until the next scan
|
||||||
if self._latest_scan_live_details is not None:
|
if self._latest_scan_live_details is not None:
|
||||||
self._latest_scan_live_details.image_count = final_image_count
|
if final_image_count is not None:
|
||||||
self._latest_scan_live_details.stitch_timestamp = last_timestamp
|
self._latest_scan_live_details.image_count = final_image_count
|
||||||
|
if last_timestamp is not None:
|
||||||
|
self._latest_scan_live_details.stitch_timestamp = last_timestamp
|
||||||
self._latest_scan_live_details.scan_phase = "Complete"
|
self._latest_scan_live_details.scan_phase = "Complete"
|
||||||
|
|
||||||
# Remove any scan folders containing zero images.
|
# Remove any scan folders containing zero images.
|
||||||
|
|
|
||||||
|
|
@ -559,7 +559,7 @@ def test_run_scan_cancelled(scan_thing_mocked_for_run_scan, caplog, mocker):
|
||||||
scan_thing, "_main_scan_loop", side_effect=InvocationCancelledError()
|
scan_thing, "_main_scan_loop", side_effect=InvocationCancelledError()
|
||||||
)
|
)
|
||||||
|
|
||||||
result, logs, calls = check_run_scan(scan_thing, caplog)
|
result, logs, calls = check_run_scan(scan_thing, caplog, InvocationCancelledError)
|
||||||
|
|
||||||
assert result == "cancelled by user"
|
assert result == "cancelled by user"
|
||||||
# No logs at warning level.
|
# No logs at warning level.
|
||||||
|
|
@ -571,7 +571,7 @@ def test_run_scan_cancelled(scan_thing_mocked_for_run_scan, caplog, mocker):
|
||||||
"cam_change_streaming_mode_calls": 2,
|
"cam_change_streaming_mode_calls": 2,
|
||||||
"main_scan_loop_calls": 1,
|
"main_scan_loop_calls": 1,
|
||||||
"return_to_start_calls": 1,
|
"return_to_start_calls": 1,
|
||||||
"perform_final_stitch_calls": 1,
|
"perform_final_stitch_calls": 0,
|
||||||
"save_scan_data_calls": 2,
|
"save_scan_data_calls": 2,
|
||||||
}
|
}
|
||||||
assert calls == expected_calls_numbers
|
assert calls == expected_calls_numbers
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue