feat(tracks): filter track list by ingest source
Add an optional `source` filter to `GET /api/v1/tracks` (and the `TrackRepository.list`/`count` port + SQLAlchemy adapter). Lets clients query, e.g., only uploaded tracks (`?source=upload`) newest-first — the backing for the webui's persistent "Recently uploaded" view. - test: upload then list with `?source=upload` (hit) / `?source=youtube` (miss) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -190,3 +190,25 @@ async def test_upload_requires_auth(api: AsyncClient) -> None:
|
||||
files={"file": ("x.mp3", b"data", "audio/mpeg")},
|
||||
)
|
||||
assert resp.status_code == 401
|
||||
|
||||
|
||||
async def test_list_tracks_filters_by_source(api: AsyncClient) -> None:
|
||||
# Uploaded tracks carry source="upload"; `?source=` narrows the list (this
|
||||
# powers the webui's "Recently uploaded" view, which survives a refresh).
|
||||
token = await _login(api)
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
await api.post(
|
||||
"/api/v1/upload",
|
||||
files={"file": ("uploaded.mp3", b"upload bytes" * 80, "audio/mpeg")},
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
hit = await api.get("/api/v1/tracks", params={"source": "upload"}, headers=headers)
|
||||
assert hit.status_code == 200, hit.text
|
||||
items = hit.json()["items"]
|
||||
assert len(items) == 1
|
||||
assert items[0]["source"] == "upload"
|
||||
|
||||
miss = await api.get("/api/v1/tracks", params={"source": "youtube"}, headers=headers)
|
||||
assert miss.status_code == 200
|
||||
assert miss.json()["items"] == []
|
||||
|
||||
Reference in New Issue
Block a user