Team Ai
Apppublic

IDKHowToCodeFr/tinyml-backend

sourceHugging Faceupdated 9h agoView on Hugging Face
1likes
test_api.py33 linesDownload Raw Back to tests
1import pytest2from fastapi.testclient import TestClient3import sys4import os5 6sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../backend')))7from main import app8 9@pytest.fixture10def client():11    with TestClient(app) as c:12        yield c13 14def test_history_endpoint(client):15    response = client.get("/history")16    assert response.status_code == 20017    assert isinstance(response.json(), list)18 19def test_dataset_endpoint(client):20    response = client.get("/dataset")21    assert response.status_code == 20022    assert isinstance(response.json(), list)23 24def test_export_tinyml_random_forest(client):25    response = client.get("/export_tinyml?model_name=rf")26    27    if response.status_code == 200:28        data = response.json()29        if "error" in data:30            assert "not found" in data["error"].lower() or "models untrained" in data["error"].lower()31        else:32            assert "code" in data or "c_code" in data33