Spaces:
Sleeping
Sleeping
| """Tests for /api/process/audio endpoint.""" | |
| from __future__ import annotations | |
| import io | |
| from fastapi.testclient import TestClient | |
| def test_audio_rejects_non_audio(client: TestClient) -> None: | |
| """Should reject non-audio content type.""" | |
| fake = io.BytesIO(b"not audio") | |
| response = client.post( | |
| "/api/process/audio", | |
| data={"options": '{"pitch_shift": 0}'}, | |
| files={"file": ("test.txt", fake, "text/plain")}, | |
| ) | |
| assert response.status_code in (400, 422) | |
| def test_audio_rejects_missing_content_type(client: TestClient) -> None: | |
| """Should reject file with no content type.""" | |
| fake = io.BytesIO(b"some bytes") | |
| response = client.post( | |
| "/api/process/audio", | |
| data={"options": '{"pitch_shift": 0}'}, | |
| files={"file": ("test.bin", fake, "")}, | |
| ) | |
| # Empty content_type should be treated as invalid | |
| assert response.status_code in (400, 422) | |
| def test_audio_rejects_missing_file(client: TestClient) -> None: | |
| """Should reject request without file.""" | |
| response = client.post( | |
| "/api/process/audio", | |
| data={"options": '{"pitch_shift": 0}'}, | |
| ) | |
| assert response.status_code == 422 | |