From d404c4584354782f398196161ae7dc209b04967f Mon Sep 17 00:00:00 2001 From: Adam Outler Date: Sat, 31 Jan 2026 15:30:01 +0000 Subject: [PATCH] Add basic unit tests --- test/api_endpoints/test_docs.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/api_endpoints/test_docs.py diff --git a/test/api_endpoints/test_docs.py b/test/api_endpoints/test_docs.py new file mode 100644 index 00000000..b8b84a80 --- /dev/null +++ b/test/api_endpoints/test_docs.py @@ -0,0 +1,24 @@ +# tests/test_root_redirect.py + + +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 + assert response.status_code == 302 + assert response.headers['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() + 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