فهرست منبع

test: the no-archive notification tests close the coroutine they capture; the Spoolman recovery tests archive under their own tmp_path instead of the shared archive/, where another worker could write the same 3MF path at the same time

maziggy 1 روز پیش
والد
کامیت
c1ea484a5a
1فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 7 1
      backend/tests/unit/test_spoolman_recovered_3mf_tracking.py

+ 7 - 1
backend/tests/unit/test_spoolman_recovered_3mf_tracking.py

@@ -59,9 +59,15 @@ async def _row(maker, archive_id: int) -> ActivePrintSpoolman | None:
 
 
 @pytest.fixture
-async def seeded(test_engine, tmp_path):
+async def seeded(test_engine, tmp_path, monkeypatch):
     from backend.app import main as main_module
+    from backend.app.core.config import settings as app_config
 
+    # Archived under this test's own directory: in the shared archive/, a test
+    # on another worker recovering the same archive id in the same second
+    # writes the same 3MF path and this one reads it half-written.
+    monkeypatch.setattr(app_config, "base_dir", tmp_path)
+    monkeypatch.setattr(app_config, "archive_dir", tmp_path / "archive")
     maker, printer_id, archive_id = await _seed(test_engine, tmp_path)
     # Empty, not whatever a test before on this worker left: the recovery reads
     # the printed plate from it, and a plate the 3MF has no usage for tracks