First product
This commit is contained in:
parent
778da9e2fc
commit
4433d7d2c4
157 changed files with 23975 additions and 0 deletions
25
tests/unit/test_healthz.py
Normal file
25
tests/unit/test_healthz.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from unittest.mock import AsyncMock
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
|
||||
|
||||
def test_healthz_returns_200_when_database_is_available(monkeypatch) -> None:
|
||||
monkeypatch.setattr("app.web.routers.health.check_database", AsyncMock(return_value=True))
|
||||
client = TestClient(app)
|
||||
|
||||
response = client.get("/healthz")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"status": "ok"}
|
||||
|
||||
|
||||
def test_healthz_returns_500_when_database_is_unavailable(monkeypatch) -> None:
|
||||
monkeypatch.setattr("app.web.routers.health.check_database", AsyncMock(return_value=False))
|
||||
client = TestClient(app)
|
||||
|
||||
response = client.get("/healthz")
|
||||
|
||||
assert response.status_code == 500
|
||||
assert response.json()["detail"] == "database unavailable"
|
||||
Loading…
Add table
Add a link
Reference in a new issue