55
66from fmu_settings_api .__main__ import app
77from fmu_settings_api .config import settings
8+ from fmu_settings_api .models import HealthCheck
89
910client = TestClient (app )
1011
1415def test_health_check_no_session () -> None :
1516 """Test the health check endpoint with missing token and no session."""
1617 response = client .get (ROUTE )
17- assert response .status_code == status .HTTP_401_UNAUTHORIZED
18+ assert response .status_code == status .HTTP_401_UNAUTHORIZED , response . json ()
1819 assert response .json () == {"detail" : "No active session found" }
1920
2021
2122def test_health_check_no_session_bad_token () -> None :
2223 """Test the health check endpoint with an invalid token but no session."""
2324 token = "no" * 32
2425 response = client .get (ROUTE , headers = {settings .TOKEN_HEADER_NAME : token })
25- assert response .status_code == status .HTTP_401_UNAUTHORIZED
26+ assert response .status_code == status .HTTP_401_UNAUTHORIZED , response . json ()
2627 assert response .json () == {"detail" : "No active session found" }
2728
2829
2930def test_health_check_no_session_valid_token (mock_token : str ) -> None :
3031 """Test the health check endpoint with a valid token but no session."""
3132 response = client .get (ROUTE , headers = {settings .TOKEN_HEADER_NAME : mock_token })
32- assert response .status_code == status .HTTP_401_UNAUTHORIZED
33+ assert response .status_code == status .HTTP_401_UNAUTHORIZED , response . json ()
3334 assert response .json () == {"detail" : "No active session found" }
3435
3536
3637def test_health_check_no_session_valid_session (client_with_session : TestClient ) -> None :
3738 """Test the health check endpoint with a valid session."""
3839 response = client_with_session .get (ROUTE )
39- assert response .status_code == status .HTTP_200_OK
40+ assert response .status_code == status .HTTP_200_OK , response . json ()
4041 assert response .json () == {"status" : "ok" }
42+ assert HealthCheck () == HealthCheck .model_validate (response .json ())
4143
4244
4345def test_health_check_no_session_valid_session_invalid_token (
@@ -48,8 +50,9 @@ def test_health_check_no_session_valid_session_invalid_token(
4850 response = client_with_session .get (
4951 ROUTE , headers = {settings .TOKEN_HEADER_NAME : token }
5052 )
51- assert response .status_code == status .HTTP_200_OK
53+ assert response .status_code == status .HTTP_200_OK , response . json ()
5254 assert response .json () == {"status" : "ok" }
55+ assert HealthCheck () == HealthCheck .model_validate (response .json ())
5356
5457
5558def test_health_check_no_session_valid_session_valid_token (
@@ -59,5 +62,6 @@ def test_health_check_no_session_valid_session_valid_token(
5962 response = client_with_session .get (
6063 ROUTE , headers = {settings .TOKEN_HEADER_NAME : mock_token }
6164 )
62- assert response .status_code == status .HTTP_200_OK
65+ assert response .status_code == status .HTTP_200_OK , response . json ()
6366 assert response .json () == {"status" : "ok" }
67+ assert HealthCheck () == HealthCheck .model_validate (response .json ())
0 commit comments