-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_main.py
37 lines (27 loc) · 905 Bytes
/
test_main.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
import pytest
from fastapi.testclient import TestClient
from fastapp.main import app
@pytest.fixture(scope="module")
def client() -> TestClient:
return TestClient(app)
@pytest.mark.parametrize("version", ("v1",))
def test_get_heartbeat(client, version):
# arrange
path = f"/{version}/health/heartbeat"
headers = {
"x-ms-auth-internal-token": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="
}
# action
response = client.get(path, headers=headers)
# assert
assert response.status_code == 200
assert response.json() == {"isAlive": True}
@pytest.mark.parametrize("version", ("v1",))
def test_post_sample(client, version):
# arrange
path = f"/{version}/sample/sample"
# action
response = client.post(path, json={"input": "Test"})
# assert
assert response.status_code == 200
assert response.json() == {"output": "Hello Test"}