Spaces:
Runtime error
Runtime error
Update test_main.py
Browse files- test_main.py +5 -5
test_main.py
CHANGED
@@ -10,20 +10,20 @@ def test_welcome():
|
|
10 |
# Test the welcome endpoint
|
11 |
response = client.get("/")
|
12 |
assert response.status_code == 200
|
13 |
-
assert response.json() == "
|
14 |
|
15 |
# Test the sentiment analysis endpoint for positive sentiment
|
16 |
def test_positive_sentiment():
|
17 |
with client:
|
18 |
# Define the request payload
|
19 |
# Initialize payload as a TextInput object
|
20 |
-
payload = TextInput(text="I love
|
21 |
|
22 |
# Convert TextInput object to JSON-serializable dictionary
|
23 |
payload_dict = jsonable_encoder(payload)
|
24 |
|
25 |
# Send a POST request to the sentiment analysis endpoint
|
26 |
-
response = client.post("/
|
27 |
|
28 |
# Assert that the response status code is 200 OK
|
29 |
assert response.status_code == 200
|
@@ -36,13 +36,13 @@ def test_negative_sentiment():
|
|
36 |
with client:
|
37 |
# Define the request payload
|
38 |
# Initialize payload as a TextInput object
|
39 |
-
payload = TextInput(text="I'm
|
40 |
|
41 |
# Convert TextInput object to JSON-serializable dictionary
|
42 |
payload_dict = jsonable_encoder(payload)
|
43 |
|
44 |
# Send a POST request to the sentiment analysis endpoint
|
45 |
-
response = client.post("/
|
46 |
|
47 |
# Assert that the response status code is 200 OK
|
48 |
assert response.status_code == 200
|
|
|
10 |
# Test the welcome endpoint
|
11 |
response = client.get("/")
|
12 |
assert response.status_code == 200
|
13 |
+
assert response.json() == "Text Classification API"
|
14 |
|
15 |
# Test the sentiment analysis endpoint for positive sentiment
|
16 |
def test_positive_sentiment():
|
17 |
with client:
|
18 |
# Define the request payload
|
19 |
# Initialize payload as a TextInput object
|
20 |
+
payload = TextInput(text="I love to watch horror and Si-Fi movies! It's amazing!")
|
21 |
|
22 |
# Convert TextInput object to JSON-serializable dictionary
|
23 |
payload_dict = jsonable_encoder(payload)
|
24 |
|
25 |
# Send a POST request to the sentiment analysis endpoint
|
26 |
+
response = client.post("/input/{text}", json=payload_dict)
|
27 |
|
28 |
# Assert that the response status code is 200 OK
|
29 |
assert response.status_code == 200
|
|
|
36 |
with client:
|
37 |
# Define the request payload
|
38 |
# Initialize payload as a TextInput object
|
39 |
+
payload = TextInput(text="I'm not satisfied by this movie. It's terrible.")
|
40 |
|
41 |
# Convert TextInput object to JSON-serializable dictionary
|
42 |
payload_dict = jsonable_encoder(payload)
|
43 |
|
44 |
# Send a POST request to the sentiment analysis endpoint
|
45 |
+
response = client.post("/input/{text}", json=payload_dict)
|
46 |
|
47 |
# Assert that the response status code is 200 OK
|
48 |
assert response.status_code == 200
|