generated from pamelafox/simple-fastapi-azure-function
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathtest_fastapi.py
35 lines (23 loc) · 793 Bytes
/
test_fastapi.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
import random
import pytest
from fastapi.testclient import TestClient
from api.fastapi_app import create_app
@pytest.fixture
def client():
return TestClient(create_app())
def test_generate_name(client):
random.seed(1)
response = client.get("/generate_name")
assert response.status_code == 200
assert response.json() == {"name": "Margaret"}
def test_generate_name_params(client):
random.seed(1)
response = client.get("/generate_name", params={"starts_with": "n"})
assert response.status_code == 200
assert response.json() == {"name": "Noa"}
def test_docs(client):
response = client.get("/docs")
assert response.status_code == 200
def test_openapi(client):
response = client.get("/openapi.json")
assert response.status_code == 200