38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from fastapi.testclient import TestClient
|
|
from app.main import app
|
|
|
|
c = TestClient(app)
|
|
|
|
|
|
def test_podcast_search_mocked(monkeypatch):
|
|
from app.services import streamrip_service as svc
|
|
|
|
async def fake_podcasts(query, limit):
|
|
assert query == "flauschig"
|
|
return [{
|
|
"source": "deezer", "media_type": "podcast", "id": "100",
|
|
"title": "Fest & Flauschig", "artist": "",
|
|
"desc": "Fest & Flauschig", "cover": None,
|
|
}]
|
|
|
|
monkeypatch.setattr(svc, "search_podcasts", fake_podcasts)
|
|
r = c.get("/api/search", params={"type": "podcast", "q": "flauschig"})
|
|
assert r.status_code == 200
|
|
assert r.json()["results"][0]["id"] == "100"
|
|
|
|
|
|
def test_podcast_detail_mocked(monkeypatch):
|
|
from app.api import podcast as pc
|
|
|
|
async def fake_details(show_id):
|
|
return {
|
|
"id": show_id, "title": "Fest & Flauschig", "description": "d",
|
|
"cover": None, "link": "https://www.deezer.com/show/1", "fans": 5,
|
|
"episodes": [{"id": "9", "title": "Ep 1", "duration": 600, "release_date": "2026-01-01"}],
|
|
}
|
|
|
|
monkeypatch.setattr(pc, "get_podcast_details", fake_details)
|
|
r = c.get("/api/podcast/1")
|
|
assert r.status_code == 200
|
|
assert len(r.json()["episodes"]) == 1
|