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"}