فهرست منبع

Tests: timelapse job tests use their own temp folder

- the route writes uploaded audio to the system temp folder as
  audio_<archive id>_*, and three tests check that nothing is left
  there; every test worker's first archive is id 1, so a check could
  see another worker's upload while it was still in progress
- the data_dir fixture now points tempfile at the test's own folder
maziggy 1 روز پیش
والد
کامیت
32a7dcca8e
1فایلهای تغییر یافته به همراه8 افزوده شده و 0 حذف شده
  1. 8 0
      backend/tests/integration/test_timelapse_editor_job.py

+ 8 - 0
backend/tests/integration/test_timelapse_editor_job.py

@@ -22,9 +22,17 @@ def _no_jobs():
 
 
 @pytest.fixture
 @pytest.fixture
 def data_dir(tmp_path):
 def data_dir(tmp_path):
+    import tempfile
+
     from backend.app.api.routes import archives
     from backend.app.api.routes import archives
 
 
+    # The route's temp files go to the system temp dir, which all test
+    # workers share; their archives all have id 1, so a check for leftover
+    # "*_1_*" files there saw another worker's upload.
+    own_tmp = tmp_path / "tmp"
+    own_tmp.mkdir()
     with (
     with (
+        patch.object(tempfile, "tempdir", str(own_tmp)),
         patch.object(archives.settings, "base_dir", tmp_path),
         patch.object(archives.settings, "base_dir", tmp_path),
         patch("backend.app.services.timelapse_processor.get_ffmpeg_path", return_value="/usr/bin/ffmpeg"),
         patch("backend.app.services.timelapse_processor.get_ffmpeg_path", return_value="/usr/bin/ffmpeg"),
     ):
     ):