feat(music): list and select playlist songs by their position

This commit is contained in:
imSp4rky
2026-11-30 12:39:51 -07:00
parent 40114fff19
commit 70ace41201
16 changed files with 222 additions and 38 deletions
@@ -177,6 +177,20 @@ def test_list_tracks_stamps_the_service_flags(monkeypatch: pytest.MonkeyPatch, w
assert all((t["anime"], t["daily"]) == (True, True) for t in titles)
def test_list_tracks_selects_a_playlist_song_by_position(monkeypatch: pytest.MonkeyPatch) -> None:
songs = [
Song(f"song-{album}", _FakeSvc, "Track", "Artist", album, track, disc, position=position)
for album, track, disc, position in (("Z", 1, 1, 1), ("B", 6, 2, 2), ("A", 2, 1, 3))
]
monkeypatch.setattr(handlers, "validate_service", lambda tag, request=None: "FAKE")
monkeypatch.setattr(handlers, "launch_served", lambda *a, **kw: handlers.Launched(_FakeService(songs), None, None))
response = asyncio.run(handlers.list_tracks_handler({"service": "FAKE", "title_id": "t1", "wanted": "2"}))
title = json.loads(response.body)["title"]
assert (title["id"], title["position"], title["track"]) == ("song-B", 2, 6)
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, "launch_served", lambda *a, **kw: handlers.Launched(_FakeService([ep()]), None, None))