Spaces:
Sleeping
Sleeping
File size: 1,187 Bytes
26ff02c 1180a53 1a42889 26ff02c 1180a53 26ff02c 1180a53 26ff02c 1180a53 26ff02c 1180a53 26ff02c 1180a53 26ff02c 1180a53 |
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
from fastapi.testclient import TestClient
from src.app import app
import os
os.environ["SKIP_DATA_PREP"] = "true"
client = TestClient(app)
def test_home_page():
response = client.get("/")
assert response.status_code == 200
assert "Benvenuto" in response.text
def test_predict_endpoint_get():
response = client.get("/predict")
assert response.status_code == 200
assert "Testa il Modello" in response.text
def test_predict_endpoint_post():
response = client.post("/predict", data={"text": "I love this!"})
assert response.status_code == 200
assert any(label in response.text for label in ["positive", "neutral", "negative"])
def test_random_tweet_page():
response = client.get("/random_tweet")
assert response.status_code == 200
assert any(
lbl in response.text
for lbl in ["positive", "neutral", "negative", "Positivo", "Neutro", "Negativo"]
)
def test_random_youtube_page():
response = client.get("/random_youtube_comment")
assert response.status_code == 200
assert any(
lbl in response.text
for lbl in ["positive", "neutral", "negative", "Positivo", "Neutro", "Negativo"]
)
|