Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
cyri113 committed Sep 13, 2024
1 parent 34ea417 commit 18ce27e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__pycache__
__pycache__
.pytest_cache
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
pipe = pipeline("text-classification", model="shahrukhx01/question-vs-statement-classifier")

custom_labels = {
"LABEL_0": "statement",
"LABEL_1": "question"
"LABEL_0": "STATEMENT",
"LABEL_1": "QUESTION"
}

class Payload(BaseModel):
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
fastapi[standard]==0.114.1
pydantic==2.8.0
transformers[torch]==4.44.2
transformers[torch]==4.44.2
pytest==8.3.3
httpx==0.27.2
10 changes: 10 additions & 0 deletions test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from fastapi.testclient import TestClient
from main import app

client = TestClient(app)

def test_route():
response = client.post('/test', json={ "text": "Is this a test?" })
assert response.status_code == 200
assert response.json()['label'] == 'QUESTION'

0 comments on commit 18ce27e

Please sign in to comment.