From 15242fe36ec262e4f1d97fb89e78494b7b9881af Mon Sep 17 00:00:00 2001 From: maziggy Date: Tue, 7 Jul 2026 12:44:53 +0200 Subject: [PATCH] test(updates): isolate _update_status global to fix CI-only flake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POST /updates/apply short-circuits (returning a payload without the per-branch keys like is_windows_installer) when the module-global _update_status is downloading/installing. A prior test leaving an apply flow mid-update made test_apply_update_windows_installer_rejection hit that guard instead of the Windows branch — an order-dependent flake that passed locally but failed on the sharded CI run with KeyError: 'is_windows_installer'. Add an autouse fixture resetting _update_status to idle before each TestUpdatesAPI test. --- .gitignore | 3 +++ backend/tests/integration/test_updates_api.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index fed8e4e33..72b114b1f 100644 --- a/.gitignore +++ b/.gitignore @@ -92,3 +92,6 @@ gitleaks-report.json scripts/pip-audit.sh security/ + +test_pipeline_archive_source.3mf +test_pipeline_run_1.3mf diff --git a/backend/tests/integration/test_updates_api.py b/backend/tests/integration/test_updates_api.py index a0ae02ccb..f00548269 100644 --- a/backend/tests/integration/test_updates_api.py +++ b/backend/tests/integration/test_updates_api.py @@ -8,6 +8,24 @@ from httpx import AsyncClient class TestUpdatesAPI: + @pytest.fixture(autouse=True) + def _reset_update_status(self): + """Isolate the module-global ``_update_status`` between tests. + + ``POST /updates/apply`` short-circuits (line 850) when ``_update_status`` + is ``"downloading"``/``"installing"``, returning a payload WITHOUT the + per-branch keys (``is_windows_installer`` etc.). A prior test that let an + apply flow run leaves the global mid-update, so a later test in the same + parallel worker hits the guard instead of its intended branch. This is + order-dependent — it passes locally but flakes on CI's sharded run + (``test_apply_update_windows_installer_rejection`` KeyError). Reset to + idle before every test so the guard never fires spuriously. + """ + from backend.app.api.routes import updates as updates_module + + updates_module._update_status = {"status": "idle", "progress": 0, "message": "", "error": None} + yield + @pytest.mark.asyncio async def test_get_version(self, async_client: AsyncClient): response = await async_client.get("/api/v1/updates/version")