Spaces:
Runtime error
Runtime error
Download backend/tests/test_api.py from IDKHowToCodeFr/tinyml-backend: direct link, hf CLI and curl.
- Browser
- Download file 829 Bytes
-
https://huggingface.co/spaces/IDKHowToCodeFr/tinyml-backend/resolve/3079b37e46b646bbc28efeca055db307597fd2d5/backend/tests/test_api.py
- Command line
-
hf download hf://spaces/IDKHowToCodeFr/tinyml-backend@3079b37e46b646bbc28efeca055db307597fd2d5/backend/tests/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/IDKHowToCodeFr/tinyml-backend/resolve/3079b37e46b646bbc28efeca055db307597fd2d5/backend/tests/test_api.py
829 Bytes
| import pytest | |
| from fastapi.testclient import TestClient | |
| import sys | |
| import os | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from main import app | |
| client = TestClient(app) | |
| def test_history_endpoint(): | |
| response = client.get("/history") | |
| assert response.status_code == 200 | |
| assert isinstance(response.json(), list) | |
| def test_dataset_endpoint(): | |
| response = client.get("/dataset") | |
| assert response.status_code == 200 | |
| assert isinstance(response.json(), list) | |
| def test_export_tinyml_random_forest(): | |
| response = client.get("/export_tinyml?model_name=rf") | |
| if response.status_code == 200: | |
| data = response.json() | |
| if "error" in data: | |
| assert "not found" in data["error"].lower() | |
| else: | |
| assert "code" in data or "c_code" in data | |