- 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
29 lines
852 B
Python
29 lines
852 B
Python
"""Router tests - Radio endpoints."""
|
|
|
|
|
|
class TestListStations:
|
|
def test_list_stations(self, client):
|
|
r = client.get("/api/radio/stations?limit=5")
|
|
assert r.status_code == 200
|
|
assert isinstance(r.json(), list)
|
|
|
|
def test_list_with_country(self, client):
|
|
r = client.get("/api/radio/stations?country=US&limit=3")
|
|
assert r.status_code == 200
|
|
|
|
|
|
class TestNearbyStations:
|
|
def test_nearby(self, client):
|
|
r = client.get("/api/radio/nearby?lat=40.7&lon=-74.0&radius=100")
|
|
assert r.status_code == 200
|
|
assert isinstance(r.json(), list)
|
|
|
|
|
|
class TestCurrentPlaying:
|
|
def test_current(self, client):
|
|
r = client.get("/api/radio/current")
|
|
assert r.status_code == 200
|
|
data = r.json()
|
|
assert data["is_playing"] is False
|
|
assert data["station"] is None
|