Skip to content

Commit

Permalink
Pytest for post /predict endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo.arenas committed Feb 8, 2021
1 parent 57f5cb7 commit 84c7d8e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

#Pycharm
.idea
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ pytest==5.4.3
scikit-learn==0.24
joblib==0.16.0
gunicorn==20.0.4
pytest==6.2.2
locust==1.4.3
Empty file added tests/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions tests/test_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from fastapi.testclient import TestClient
from app import app


def test_success_prediction():
endpoint = '/predict'
body = {"data": [[4.8, 3, 1.4, 0.3], [2, 1, 3.2, 1.1]]}

with TestClient(app) as client:
response = client.post(endpoint, json=body)
response_json = response.json()
assert response.status_code == 200
assert 'prediction' in response_json

0 comments on commit 84c7d8e

Please sign in to comment.