@@ -46,6 +46,7 @@ def test_get_health(client_with_session: TestClient, session_tmp_path: Path) ->
4646 """Test 401 returns when the user has no SMDA API key set in their configuration."""
4747 response = client_with_session .get (f"{ ROUTE } /health" )
4848 assert response .status_code == status .HTTP_401_UNAUTHORIZED , response .json ()
49+ assert response .headers ["x-upstream-source" ] == "SMDA"
4950 assert response .json ()["detail" ] == "User SMDA API key is not configured"
5051
5152
@@ -64,6 +65,7 @@ def test_get_health_has_user_api_key(
6465
6566 response = client_with_session .get (f"{ ROUTE } /health" )
6667 assert response .status_code == status .HTTP_401_UNAUTHORIZED , response .json ()
68+ assert response .headers ["x-upstream-source" ] == "SMDA"
6769 assert response .json ()["detail" ] == "SMDA access token is not set"
6870
6971
@@ -72,7 +74,7 @@ async def test_get_health_has_user_api_key_and_access_token(
7274 session_tmp_path : Path ,
7375 mock_SmdaAPI_get : AsyncMock ,
7476) -> None :
75- """Test 401 returns when an API key exists but an SMDA access token is not set."""
77+ """Test 200 returns when an API key and SMDA access token are set."""
7678 mock_response = MagicMock (spec = httpx .Response )
7779 mock_response .status_code = httpx .codes .OK
7880 mock_response .json .return_value = {"status" : "ok" }
@@ -81,6 +83,7 @@ async def test_get_health_has_user_api_key_and_access_token(
8183
8284 response = client_with_smda_session .get (f"{ ROUTE } /health" )
8385 assert response .status_code == status .HTTP_200_OK , response .json ()
86+ assert response .headers ["x-upstream-source" ] == "SMDA"
8487 assert response .json ()["status" ] == "ok"
8588
8689
@@ -103,8 +106,8 @@ async def test_get_health_request_failure_raises_exception(
103106 response = client_with_smda_session .get (f"{ ROUTE } /health" )
104107
105108 assert response .status_code == status .HTTP_401_UNAUTHORIZED , response .json ()
106- assert response .json ()["detail" ] == "SMDA error requesting https://smda"
107109 assert response .headers ["x-upstream-source" ] == "SMDA"
110+ assert response .json ()["detail" ] == "SMDA error requesting https://smda"
108111
109112
110113async def test_post_field_succeeds_with_one (
@@ -135,6 +138,7 @@ async def test_post_field_succeeds_with_one(
135138 f"{ ROUTE } /field" , json = {"identifier" : "TROLL" }
136139 )
137140 assert response .status_code == status .HTTP_200_OK , response .json ()
141+ assert response .headers ["x-upstream-source" ] == "SMDA"
138142 assert SmdaFieldSearchResult .model_validate (
139143 response .json ()
140144 ) == SmdaFieldSearchResult (
@@ -169,6 +173,7 @@ async def test_post_field_succeeds_with_none(
169173 )
170174
171175 assert response .status_code == status .HTTP_200_OK , response .json ()
176+ assert response .headers ["x-upstream-source" ] == "SMDA"
172177 assert SmdaFieldSearchResult .model_validate (
173178 response .json ()
174179 ) == SmdaFieldSearchResult (
@@ -198,6 +203,7 @@ async def test_post_field_with_no_identifier_raises(
198203 response = client_with_smda_session .post (f"{ ROUTE } /field" , json = {"identifier" : "" })
199204
200205 assert response .status_code == status .HTTP_200_OK , response .json ()
206+ assert response .headers ["x-upstream-source" ] == "SMDA"
201207 assert SmdaFieldSearchResult .model_validate (
202208 response .json ()
203209 ) == SmdaFieldSearchResult (
@@ -223,6 +229,7 @@ async def test_post_field_has_bad_response_raises(
223229 assert response .status_code == status .HTTP_500_INTERNAL_SERVER_ERROR , (
224230 response .json ()
225231 )
232+ assert response .headers ["x-upstream-source" ] == "SMDA"
226233 assert (
227234 response .json ()["detail" ]
228235 == "Malformed response from SMDA: no 'data' field present"
@@ -319,6 +326,7 @@ async def test_post_masterdata_success(
319326 )
320327
321328 assert response .status_code == status .HTTP_200_OK , response .json ()
329+ assert response .headers ["x-upstream-source" ] == "SMDA"
322330 response_data = response .json ()
323331 assert len (response_data ["field" ]) == 1
324332 assert response_data ["field" ][0 ]["identifier" ] == "DROGON"
@@ -399,6 +407,7 @@ async def test_post_masterdata_missing_coordinate_system(
399407 )
400408
401409 assert response .status_code == status .HTTP_404_NOT_FOUND , response .json ()
410+ assert response .headers ["x-upstream-source" ] == "SMDA"
402411 assert "Projected field coordinate system not found" in response .json ()["detail" ]
403412
404413
@@ -425,6 +434,7 @@ async def test_post_masterdata_malformed_response(
425434 assert response .status_code == status .HTTP_500_INTERNAL_SERVER_ERROR , (
426435 response .json ()
427436 )
437+ assert response .headers ["x-upstream-source" ] == "SMDA"
428438 assert "Malformed response from SMDA" in response .json ()["detail" ]
429439
430440
@@ -500,6 +510,7 @@ async def test_post_masterdata_multiple_fields(
500510 )
501511
502512 assert response .status_code == status .HTTP_200_OK , response .json ()
513+ assert response .headers ["x-upstream-source" ] == "SMDA"
503514 response_data = response .json ()
504515 assert len (response_data ["field" ]) == 2 # noqa
505516
@@ -586,5 +597,5 @@ async def test_post_masterdata_request_fails(
586597 )
587598
588599 assert response .status_code == status .HTTP_401_UNAUTHORIZED , response .json ()
589- assert response .json ()["detail" ] == "SMDA error requesting https://smda"
590600 assert response .headers ["x-upstream-source" ] == "SMDA"
601+ assert response .json ()["detail" ] == "SMDA error requesting https://smda"
0 commit comments