forked from zjesko/mlops-iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app.py
More file actions
23 lines (20 loc) · 700 Bytes
/
test_app.py
File metadata and controls
23 lines (20 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from fastapi.testclient import TestClient
from main import app
def test_ping():
with TestClient(app) as client:
response = client.get("/ping")
assert response.status_code == 200
assert response.json() == {"ping":"pong"}
def test_pred_virginica():
payload = {
"sepal_length": 3,
"sepal_width": 5,
"petal_length": 3.2,
"petal_width": 4.4
}
with TestClient(app) as client:
response = client.post('/predict_flower', json=payload)
flower_result = response.json()['flower_class']
assert response.status_code == 200
print(f"response.json()={response.json()}")
assert flower_result == "Iris Virginica"