OverviewFilesCommitsIssuesDocsReleasesPeers

stremio-vsembed commits / e7565b9

Two tests that depended on the machine they ran on
test_a_fixed_height_still_redirects checked that /vidcore/...?h=720 redirects to the 720p variant. The route looks for a local copy BEFORE resolving, and tmdb:138502 S02E07 -- the episode the test uses -- is a real 613 MB file in the real mp4-cache on this machine. So it found it and redirected to /mp4/ instead. Working out the library path also reached TMDB over the network, from a unit test. Both are now pointed at tmp_path. The second was worse than a wrong result. test_ingest_queue starts a real job, and _start_mp4_job spawns a thread whose final _set_job_state runs whenever that thread gets there. Left to escape, it lands after monkeypatch has restored INGEST_QUEUE_FILE and writes to the REAL queue -- which is exactly how a run of this suite left `series:tmdb:1:1:1:720` sitting in production. The fixture now joins those threads before the patches come off, which covers any test that starts a job rather than only the ones that exist today. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
e7565b93d183ef6bf6aaf3d00a6472cd7d76304a
by plankatron <fleeky@gmail.com> · 2026-08-31T15:06:30.000Z

Changed files (2) +20 -1

test_ingest_queue.py +10 -0
……@@ -14,6 +14,7 @@ Run: .venv/bin/python3 -m pytest test_ingest_queue.py -q
1414
1515import json
1616import os
17import threading
1718
1819import pytest
1920
……@@ -27,6 +28,15 @@ def queue_file(tmp_path, monkeypatch):
2728 monkeypatch.setattr(addon, "_mp4_jobs", {})
2829 monkeypatch.setattr(addon, "LIBRARY_ROOT", str(tmp_path / "lib"))
2930 yield
31 # _start_mp4_job spawns a real thread, and its final _set_job_state runs
32 # whenever that thread gets there. Left to escape, it lands AFTER monkeypatch
33 # has restored INGEST_QUEUE_FILE and writes to the REAL queue -- which is
34 # how a run of this suite once left `series:tmdb:1:1:1:720` in production.
35 # Joined here rather than in the tests: any test that starts a job has the
36 # same problem, including ones not yet written.
37 for t in threading.enumerate():
38 if t.name.startswith("mp4-") and t is not threading.current_thread():
39 t.join(10)
3040
3141
3242def _load():
test_vidcore_adaptive.py +10 -1
……@@ -129,9 +129,18 @@ def test_never_returns_an_empty_ladder():
129129# --- the route --------------------------------------------------------------
130130
131131@pytest.fixture
132def client(monkeypatch):
132def client(monkeypatch, tmp_path):
133133 monkeypatch.setattr(addon, "_resolve_vidcore", lambda *a, **k: MASTER_URL)
134134 monkeypatch.setattr(addon, "_prefetch_vidcore", lambda *a, **k: None)
135 # The route checks for a local copy BEFORE resolving, so without these the
136 # test depends on the developer's disk: tmdb:138502 S02E07 is a real file in
137 # the real mp4-cache on the machine this was written on, and h=720 found it
138 # and redirected to /mp4/ instead of the variant. Working out the library
139 # path also reaches TMDB over the network, from a unit test.
140 monkeypatch.setattr(addon, "MP4_DIR", str(tmp_path / "cache"))
141 monkeypatch.setattr(addon, "LIBRARY_ROOT", str(tmp_path / "lib"))
142 monkeypatch.setattr(addon, "_library_meta", lambda *a, **k: None)
143 monkeypatch.setattr(addon, "_ensure_ingest", lambda *a, **k: None)
135144 return addon.app.test_client()
136145
137146