blob: cbab286cbab0c547fd7677c8f4d610de56f4328a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
from http import HTTPStatus
from fastapi.testclient import TestClient
from kennel.main import app
from structlog.testing import capture_logs
client = TestClient(app)
def test_healthcheck():
response = client.get("/healthcheck")
assert response.status_code == HTTPStatus.OK
assert response.text == ""
def test_read_main():
# Example of testing logging using a context manager
with capture_logs() as cap_logs:
response = client.get("/")
assert {"event": "In root path", "log_level": "info"} in cap_logs
assert response.status_code == HTTPStatus.OK
assert response.json() == {"msg": "Hello World"}
|