- Add pytest config with 90% coverage threshold - 15 test files covering all routers, services, schemas, models - 300 tests: unit tests, integration tests, edge cases, mocked external APIs - Update CI workflow to run pytest with coverage enforcement - Mock external services (Genius, MusicBrainz, RadioBrowser) - In-memory SQLite DB per test via conftest fixtures
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""Router tests - LoFi endpoints."""
|
|
from app.models.lofi import LofiChannel
|
|
from app.db.database import SessionLocal
|
|
|
|
|
|
class TestListChannels:
|
|
def test_list_channels(self, client):
|
|
r = client.get("/api/lofi/channels")
|
|
assert r.status_code == 200
|
|
channels = r.json()
|
|
assert len(channels) >= 3
|
|
assert all("stream_url" in c for c in channels)
|
|
|
|
|
|
class TestAddChannel:
|
|
def test_add_channel(self, client):
|
|
r = client.post("/api/lofi/add", json={
|
|
"name": "Custom Lofi",
|
|
"stream_url": "https://example.com/stream",
|
|
"description": "Custom channel"
|
|
})
|
|
assert r.status_code == 200
|
|
data = r.json()
|
|
assert data["name"] == "Custom Lofi"
|
|
assert data["source_platform"] == "youtube"
|
|
|
|
def test_add_duplicate(self, client):
|
|
client.post("/api/lofi/add", json={"name": "Dup", "stream_url": "https://a.com"})
|
|
r = client.post("/api/lofi/add", json={"name": "Dup", "stream_url": "https://b.com"})
|
|
assert r.status_code == 400
|