File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Tests for YLE media endpoint routing."""
2+
3+ from fastapi .testclient import TestClient
4+
5+ from app .main import app
6+
7+
8+ client = TestClient (app )
9+
10+
11+ def test_yle_media_endpoint (monkeypatch ):
12+ """The canonical YLE media route should resolve program IDs."""
13+ monkeypatch .setattr ("app.routers.media.map_yle_content" , lambda pid : f"mapped:{ pid } " )
14+
15+ response = client .get ("/v1/yle-media/1-50525862" )
16+
17+ assert response .status_code == 200
18+ assert response .json () == "mapped:1-50525862"
19+
20+
21+ def test_yle_media_compat_endpoint (monkeypatch ):
22+ """Compatibility route should handle accidentally prefixed YLE URLs."""
23+ monkeypatch .setattr ("app.routers.media.map_yle_content" , lambda pid : f"mapped:{ pid } " )
24+
25+ response = client .get ("/v1/media/v1/yle-media/1-50525862" )
26+
27+ assert response .status_code == 200
28+ assert response .json () == "mapped:1-50525862"
You can’t perform that action at this time.
0 commit comments