-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_app.py
62 lines (47 loc) · 1.89 KB
/
test_app.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
from fastapi.testclient import TestClient
from .app.server import app
os.chdir('app')
client = TestClient(app)
"""
This part is optional.
We've built our web application, and containerized it with Docker.
But imagine a team of ML engineers and scientists that needs to maintain, improve and scale this service over time.
It would be nice to write some tests to ensure we don't regress!
1. `Pytest` is a popular testing framework for Python. If you haven't used it before, take a look at https://docs.pytest.org/en/7.1.x/getting-started.html to get started and familiarize yourself with this library.
2. How do we test FastAPI applications with Pytest? Glad you asked, here's two resources to help you get started:
(i) Introduction to testing FastAPI: https://fastapi.tiangolo.com/tutorial/testing/
(ii) Testing FastAPI with startup and shutdown events: https://fastapi.tiangolo.com/advanced/testing-events/
"""
def test_root():
"""
[TO BE IMPLEMENTED]
Test the root ("/") endpoint, which just returns a {"Hello": "World"} json response
"""
pass
def test_predict_empty():
"""
[TO BE IMPLEMENTED]
Test the "/predict" endpoint, with an empty request body
"""
pass
def test_predict_en_lang():
"""
[TO BE IMPLEMENTED]
Test the "/predict" endpoint, with an input text in English (you can use one of the test cases provided in README.md)
"""
pass
def test_predict_es_lang():
"""
[TO BE IMPLEMENTED]
Test the "/predict" endpoint, with an input text in Spanish.
Does the tokenizer and classifier handle this case correctly? Does it return an error?
"""
pass
def test_predict_non_ascii():
"""
[TO BE IMPLEMENTED]
Test the "/predict" endpoint, with an input text that has non-ASCII characters.
Does the tokenizer and classifier handle this case correctly? Does it return an error?
"""
pass