Spaces:
Sleeping
Sleeping
from fastapi.testclient import TestClient | |
from app import app | |
client = TestClient(app) | |
def test_home(): | |
response = client.get("/") | |
assert response.status_code == 200 | |
assert response.json() == {"message": "Speak your mind emotion API is running"} | |
def test_predict(): | |
test_input = {"text": "I feel fantastic today!"} | |
response = client.post("/classify-emotion", json=test_input) | |
assert response.status_code == 200 | |
assert "predicted_emotion" in response.json() | |
assert isinstance(response.json()["predicted_emotion"], str) | |
if __name__ == "__main__": | |
test_home() | |
test_predict() | |
print("All tests passed successfully!") | |