Files
NetAlertX/test/api_endpoints/test_docs.py
Adam Outler 53962bc38b Update test/api_endpoints/test_docs.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-01-31 10:41:58 -05:00

25 lines
923 B
Python

# test/api_endpoints/test_docs.py - Tests for root redirect and API docs endpoints
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'<!DOCTYPE html>' in data or b'<html>' in data