We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 82f2c56 commit 4fdf668Copy full SHA for 4fdf668
1 file changed
tests/routers/test_health.py
@@ -2,9 +2,20 @@
2
3
4
@patch("app.routers.health.check_db_status")
5
-def test_health(mock_db_status, client):
6
- db_status = {"status": "error", "message": "Database connection failed"}
+def test_health_ok(mock_db_status, client):
+ db_status = {
7
+ "status": "ok",
8
+ }
9
mock_db_status.return_value = db_status
10
r = client.get("/health")
11
assert r.status_code == 200
12
assert r.json() == {"status": "ok", "database": db_status}
13
+
14
15
+@patch("app.routers.health.check_db_status")
16
+def test_health_db_error(mock_db_status, client):
17
+ db_status = {"status": "error", "message": "Database connection failed"}
18
+ mock_db_status.return_value = db_status
19
+ r = client.get("/health")
20
+ assert r.status_code == 503
21
+ assert r.json() == {"status": "error", "database": db_status}
0 commit comments