-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_main.py
More file actions
41 lines (27 loc) · 1.1 KB
/
test_main.py
File metadata and controls
41 lines (27 loc) · 1.1 KB
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
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_get_health():
response = client.get(url="/health")
assert response.status_code == 200
assert response.json() == "OK"
def test_get_hello_1():
response = client.get(url="/everyone")
assert response.status_code == 200
assert response.json() == "Hello everyone"
def test_get_hello_2():
response = client.get(url="/devops/engineers")
assert response.status_code == 200
assert response.json() == "Hello devops, engineers"
def test_get_hello_3():
response = client.get(url="/devops/engineers/again")
assert response.status_code == 200
assert response.json() == "Hello devops, engineers, again"
def test_get_hello_4():
response = client.get(url="/devops/engineers/once/more")
assert response.status_code == 200
assert response.json() == "Hello devops, engineers, once, more"
def test_not_found():
response = client.get(url="/devops/engineers/again/and/again")
assert response.status_code == 404
assert response.json() == {"detail": "Not Found"}