-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_test.py
38 lines (29 loc) · 998 Bytes
/
app_test.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
"""
Module used for testing simple server module
"""
from fastapi.testclient import TestClient
import pytest
from application.app import app
client = TestClient(app)
class TestSimpleServer:
"""
TestSimpleServer class for testing SimpleServer
"""
@pytest.mark.asyncio
async def read_health_test(self):
"""Tests the health check endpoint"""
response = client.get("health")
assert response.status_code == 200
assert response.json() == {"health": "ok"}
@pytest.mark.asyncio
async def read_main_test(self):
"""Tests the main endpoint"""
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"msg": "Hello World"}
@pytest.mark.asyncio
async def read_bye_test(self):
"""Test bye endpoint"""
response = client.get("bye")
assert response.status_code == 200
assert response.json() == {"msg": "So long, and thanks for all the fish"}