refactor(api): build list, search and session services through one launch_served

This commit is contained in:
imSp4rky
2026-11-29 14:28:47 -07:00
parent e41760c2b3
commit de2ffcb9bd
22 changed files with 444 additions and 280 deletions
+4 -2
View File
@@ -168,7 +168,9 @@ class _FakeService:
@pytest.mark.parametrize("wanted", [None, "S01"], ids=["one-title", "episodes"])
def test_list_tracks_stamps_the_service_flags(monkeypatch: pytest.MonkeyPatch, wanted: str | None) -> None:
monkeypatch.setattr(handlers, "validate_service", lambda tag, request=None: "FAKE")
monkeypatch.setattr(handlers, "setup_list_service", lambda *a, **kw: _FakeService([ep(), ep(number=2)]))
monkeypatch.setattr(
handlers, "launch_served", lambda *a, **kw: handlers.Launched(_FakeService([ep(), ep(number=2)]), None, None)
)
response = asyncio.run(handlers.list_tracks_handler({"service": "FAKE", "title_id": "t1", "wanted": wanted}))
body = json.loads(response.body)
titles = [e["title"] for e in body["episodes"]] if wanted else [body["title"]]
@@ -178,7 +180,7 @@ def test_list_tracks_stamps_the_service_flags(monkeypatch: pytest.MonkeyPatch, w
def test_list_titles_stamps_the_service_flags(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(handlers, "validate_service", lambda tag, request=None: "FAKE")
monkeypatch.setattr(handlers, "setup_list_service", lambda *a, **kw: _FakeService([ep()]))
monkeypatch.setattr(handlers, "launch_served", lambda *a, **kw: handlers.Launched(_FakeService([ep()]), None, None))
response = asyncio.run(handlers.list_titles_handler({"service": "FAKE", "title_id": "t1"}))
title = json.loads(response.body)["titles"][0]
assert (title["anime"], title["daily"]) == (True, True)