aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth@simponic.xyz>2024-08-07 19:46:46 -0700
committerElizabeth Hunt <elizabeth@simponic.xyz>2024-08-07 19:46:46 -0700
commit6f03348e5aac33118840324a96e9321dca483b9f (patch)
treea40d550cefce75bc882c506d5ead80e39228a990 /tests
downloadkennel.hatecomputers.club-6f03348e5aac33118840324a96e9321dca483b9f.tar.gz
kennel.hatecomputers.club-6f03348e5aac33118840324a96e9321dca483b9f.zip
initial commit that i did NOT steal from anywhere
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/test_main.py22
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/__init__.py
diff --git a/tests/test_main.py b/tests/test_main.py
new file mode 100644
index 0000000..cbab286
--- /dev/null
+++ b/tests/test_main.py
@@ -0,0 +1,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"}