File size: 767 Bytes
e488f4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from fastapi.testclient import TestClient
from main import app

client = TestClient(app)
def test_positive_sentiment():
    response = client.post("/predict", json={"text": "I love this product! It's amazing."})
    assert response.status_code == 200
    assert response.json() == {"sentiment": "positive"}

def test_negative_sentiment():
    response = client.post("/predict", json={"text": "This product is terrible. I regret buying it."})
    assert response.status_code == 200
    assert response.json() == {"sentiment": "negative"}

def test_neutral_sentiment():
    response = client.post("/predict", json={"text": "This product is okay. It meets my expectations."})
    assert response.status_code == 200
    assert response.json() == {"sentiment": "neutral"}