File size: 676 Bytes
5c50bbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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!")