AroojImtiaz commited on
Commit
41d63dc
1 Parent(s): 2a0eaa3

Create test.py

Browse files
Files changed (1) hide show
  1. test.py +44 -0
test.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi.testclient import TestClient
2
+ from main import app
3
+
4
+ client = TestClient(app)
5
+
6
+ def test_positive_sentiment():
7
+ response = client.post("/analyze/", json={"text": "I'm thrilled with the results of this service!"})
8
+ assert response.status_code == 200
9
+ assert response.json() == {"sentiment": "joy"}
10
+
11
+ def test_negative_sentiment():
12
+ response = client.post("/analyze/", json={"text": "What a disappointment! It didn't meet my expectations at all."})
13
+ assert response.status_code == 200
14
+ assert response.json() == {"sentiment": "anger"}
15
+
16
+ def test_neutral_sentiment():
17
+ response = client.post("/analyze/", json={"text": "The product does exactly what it promises. Nothing more, nothing less."})
18
+ assert response.status_code == 200
19
+ assert response.json() == {"sentiment": "neutral"}
20
+
21
+ def test_anger_sentiment():
22
+ response = client.post("/analyze/", json={"text": "This app is frustrating and annoying to use!"})
23
+ assert response.status_code == 200
24
+ assert response.json() == {"sentiment": "anger"}
25
+
26
+ def test_disgust_sentiment():
27
+ response = client.post("/analyze/", json={"text": "The taste of this food is disgusting!"})
28
+ assert response.status_code == 200
29
+ assert response.json() == {"sentiment": "disgust"}
30
+
31
+ def test_fear_sentiment():
32
+ response = client.post("/analyze/", json={"text": "I'm worried that this might be unsafe."})
33
+ assert response.status_code == 200
34
+ assert response.json() == {"sentiment": "fear"}
35
+
36
+ def test_sadness_sentiment():
37
+ response = client.post("/analyze/", json={"text": "It's sad to see it perform so poorly."})
38
+ assert response.status_code == 200
39
+ assert response.json() == {"sentiment": "sadness"}
40
+
41
+ def test_surprise_sentiment():
42
+ response = client.post("/analyze/", json={"text": "Wow, I didn't expect it to be this good!"})
43
+ assert response.status_code == 200
44
+ assert response.json() == {"sentiment": "surprise"}