Skip to content

Commit 8fe6e99

Browse files
committed
Adding asserts to check the format returned and check the cotnent when 404 is returned
1 parent 74b5c5b commit 8fe6e99

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/integration/test_api.py

+21
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ def test_old_entity_gone_shown(test_data_old_entities, client, exclude_middlewar
124124
assert (
125125
f"This entity (#{old_entity.old_entity_id}) has been removed." in response.text
126126
)
127+
assert (
128+
"text/html" in response.headers["Content-Type"]
129+
), "Expected response in text/html format"
130+
131+
132+
def test_old_entity_gone_json_shown(test_data_old_entities, client, exclude_middleware):
133+
"""
134+
Test entity endpoint returns entity gone content
135+
"""
136+
old_entity = test_data_old_entities["old_entities"][410][0]
137+
response = client.get(
138+
f"/entity/{old_entity.old_entity_id}.json", allow_redirects=False
139+
)
140+
assert response.status_code == 410
141+
assert (
142+
response.headers["Content-Type"] == "application/json"
143+
), "Expected response in JSON format"
144+
assert f"Entity {old_entity.old_entity_id} has been removed" in response.text
127145

128146

129147
def test_dataset_json_endpoint_returns_as_expected(test_data, client):
@@ -308,6 +326,9 @@ def test_get_by_curie_redirects_to_entity(test_data, client, exclude_middleware)
308326
def test_get_by_curie_404s_for_unknown_reference(test_data, client, exclude_middleware):
309327
response = client.get("/curie/not:found", allow_redirects=False)
310328
assert response.status_code == 404
329+
expected_content = "Page not found"
330+
# Check if the expected content is present in the response body
331+
assert expected_content in response.text
311332

312333

313334
def test_get_dataset_unknown_returns_404(client, exclude_middleware):

0 commit comments

Comments
 (0)