Spaces:
Sleeping
Sleeping
Download tests/test_api_pytest.py from HighFive52/ml-api: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/HighFive52/ml-api/resolve/main/tests/test_api_pytest.py
- Command line
-
hf download hf://spaces/HighFive52/ml-api/tests/test_api_pytest.py
-
curl -L -o test_api_pytest.py https://huggingface.co/spaces/HighFive52/ml-api/resolve/main/tests/test_api_pytest.py
1.38 kB
| import pytest | |
| from fastapi.testclient import TestClient | |
| from app import app | |
| import io | |
| client = TestClient(app) | |
| def test_api_endpoints(endpoint, csv_content, filename): | |
| file = io.BytesIO(csv_content.encode("utf-8")) | |
| response = client.post(endpoint, files={"file": (filename, file, "text/csv")}) | |
| assert response.status_code == 200 | |
| result = response.json() | |
| assert isinstance(result, dict) | |
| assert len(result) > 0 | |
| def test_health(): | |
| response = client.get("/health") | |
| assert response.status_code == 200 | |
| assert response.json() == {"status": "ok"} | |