diff --git a/test/api_endpoints/test_docs.py b/test/api_endpoints/test_docs.py index 6c6bbabc..bc12cecf 100644 --- a/test/api_endpoints/test_docs.py +++ b/test/api_endpoints/test_docs.py @@ -6,19 +6,18 @@ from api_server import api_server_start def test_index_redirect_logic(): """Test the redirect function logic directly.""" - with api_server_start.app.test_request_context(): - response = api_server_start.index_redirect() - # In Flask, a redirect return object is a Response + with api_server_start.app.test_client() as client: + response = client.get("/", follow_redirects=False) assert response.status_code == 302 - assert response.headers['Location'] == '/docs' + assert response.location == '/docs' def test_api_docs_logic(): """Test that api_docs attempts to serve the correct file.""" - with api_server_start.app.test_request_context(): - response = api_server_start.api_docs() + with api_server_start.app.test_client() as client: + response = client.get("/docs") assert response.status_code == 200 - assert response.mimetype == 'text/html' - # Manually join the chunks from the generator - data = b"".join(response.response) - assert b'' in data or b'' in data + assert response.mimetype == "text/html" + response.direct_passthrough = False + data = response.get_data() + assert b"" in data or b"" in data