test(updates): isolate _update_status global to fix CI-only flake

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.
This commit is contained in:
maziggy
2026-07-07 12:44:53 +02:00
parent 4dc3ea7588
commit 15242fe36e
2 changed files with 21 additions and 0 deletions
+3
View File
@@ -92,3 +92,6 @@ gitleaks-report.json
scripts/pip-audit.sh
security/
test_pipeline_archive_source.3mf
test_pipeline_run_1.3mf
@@ -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")