Browse Source

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.
maziggy 1 week ago
parent
commit
18db5ed038
1 changed files with 8 additions and 0 deletions
  1. 8 0
      backend/tests/unit/test_layer_timelapse_expected_archive.py

+ 8 - 0
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()