Fix non-hermetic diet_guard gate tests depending on a real X display

test_demo_opens_window and test_bare_gate_due_opens_window never mocked
wait_for_display(), so they silently relied on a real, reachable X
display being present. On a dev machine this is always true, so they
passed; on a true headless CI runner (no X server at all) each test
blocked for the real 60s timeout before failing, explaining the CI
run's 131s duration. Mocking it to True (matching the existing
test_gate_due_but_display_not_ready_defers pattern for the False case)
restores hermeticity with no production code change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A7vbgtFfZmfxJtN5DdtJky
This commit is contained in:
Krzysztof kuhy Rudnicki 2026-06-22 08:12:02 +02:00
parent 205b214d78
commit 2de8f5d122

View File

@ -229,6 +229,7 @@ class TestGate:
patch.object(_cli, "MealGate", return_value=gate) as factory,
patch.object(_cli, "acquire_gate_lock", return_value=MagicMock()),
patch.object(_cli, "release_gate_lock"),
patch.object(_cli, "wait_for_display", return_value=True),
):
assert main(["gate", "--demo"]) == 0
factory.assert_called_once_with(demo_mode=True)
@ -248,6 +249,7 @@ class TestGate:
patch.object(_cli, "MealGate", return_value=gate),
patch.object(_cli, "acquire_gate_lock", return_value=MagicMock()),
patch.object(_cli, "release_gate_lock"),
patch.object(_cli, "wait_for_display", return_value=True),
):
assert main(["gate"]) == 0
gate.run.assert_called_once()