forked from paulscherrerinstitute/alphafold-on-fire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_health.py
35 lines (28 loc) · 1.14 KB
/
test_health.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
import operator
import pytest
from fastapi import testclient
from app import config, main
client = testclient.TestClient(main.app)
settings = config.get_settings()
def test_get_health() -> None:
response = client.get("/health")
assert response.status_code == 200
assert response.headers["content-type"] == "application/health+json"
assert response.headers["cache-control"] == "max-age=3600"
payload = response.json()
for key in ["status", "version", "releaseId", "checks"]:
assert key in payload
assert payload["status"] == "pass"
assert payload["version"] == settings.version
assert payload["releaseId"] == settings.releaseId
for key in ["postgresql:responseTime", "postgresql:uptime"]:
assert key in payload["checks"]
for item in payload["checks"][key]:
assert "componentType" in item
assert item["componentType"] == "datastore"
@pytest.mark.parametrize(
"method", ["head", "post", "put", "delete", "options", "patch"]
)
def test_health(method: str) -> None:
response = operator.methodcaller(method, "/health")(client)
assert response.status_code == 405