From ae3cb479c783fa73c9617e53f1c6164df500fc6f Mon Sep 17 00:00:00 2001 From: maziggy Date: Sat, 16 May 2026 14:11:04 +0200 Subject: [PATCH] fix(tests): disable plate detection in test_layer_timelapse_expected_archive Test was passing locally but failing in CI on the merge of v0.2.4.1. Root cause: MagicMock returns a truthy default for any unset attribute, so mock_printer.plate_detection_enabled was truthy and the production code's plate detection block ran for real. Locally with ffmpeg present the capture path completed cleanly (try/except swallowed errors) and flow continued to start_session. In CI without ffmpeg, the failure path in capture_camera_frame_bytes prevented execution from reaching the expected-archive branch's start_session call, so the assert_called_once on the patched start_session tripped. Plate detection isn't the subject under test (start_session in the expected-archive branch is). Setting plate_detection_enabled = False explicitly on the mock skips that block entirely and makes the test robust to environmental differences. Test also drops from ~9s to ~2s since real frame-capture attempts no longer run. --- .../tests/unit/test_layer_timelapse_expected_archive.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/tests/unit/test_layer_timelapse_expected_archive.py b/backend/tests/unit/test_layer_timelapse_expected_archive.py index 9afeffd20..a118bb8f6 100644 --- a/backend/tests/unit/test_layer_timelapse_expected_archive.py +++ b/backend/tests/unit/test_layer_timelapse_expected_archive.py @@ -64,6 +64,14 @@ def _build_mocks(*, external_camera_enabled: bool, external_camera_url: str | No mock_printer.external_camera_url = external_camera_url mock_printer.external_camera_type = "snapshot" mock_printer.external_camera_snapshot_url = external_camera_url + # Disable plate detection in the mock so on_print_start's plate-detection + # block is skipped entirely. Plate detection isn't the subject under test + # and its real code path tries to capture a frame — which fails differently + # in CI (no ffmpeg) vs. local dev (ffmpeg present), and the CI-only path + # somehow prevents the expected-archive branch's start_session from being + # reached. MagicMock's default attribute access returns a truthy object, + # so without this explicit False the production code enters plate detection. + mock_printer.plate_detection_enabled = False mock_printer.name = "TestA1" mock_archive = MagicMock()