Spaces:
Sleeping
Sleeping
Download tests/test_api.py from JonCard/infiniteradio: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/spaces/JonCard/infiniteradio/resolve/main/tests/test_api.py
- Command line
-
hf download hf://spaces/JonCard/infiniteradio/tests/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/JonCard/infiniteradio/resolve/main/tests/test_api.py
1.36 kB
| import pytest | |
| from app.state import radio_state | |
| def test_player_page(client): | |
| response = client.get("/") | |
| assert response.status_code == 200 | |
| assert response.headers["content-type"].startswith("text/html") | |
| assert "stream" in response.text | |
| def test_put_tempo_updates_state(client, tempo): | |
| assert client.put(f"/tempo/{tempo}").status_code == 200 | |
| assert radio_state.snapshot()[0].tempo == tempo | |
| def test_put_tempo_rejects_invalid(client, tempo): | |
| before = radio_state.snapshot() | |
| assert client.put(f"/tempo/{tempo}").status_code == 422 | |
| assert radio_state.snapshot() == before | |
| def test_post_tempo_not_allowed(client): | |
| assert client.post("/tempo/100").status_code == 405 | |
| def test_post_style_updates_state(client, spookiness): | |
| assert client.post("/style", json={"spookiness": spookiness}).status_code == 200 | |
| assert radio_state.snapshot()[0].spookiness == spookiness | |
| def test_post_style_rejects_invalid(client, body): | |
| before = radio_state.snapshot() | |
| assert client.post("/style", json=body).status_code == 422 | |
| assert radio_state.snapshot() == before | |