mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-04 09:11:34 -07:00
Coderabbit requested changes
This commit is contained in:
@@ -6,19 +6,18 @@ from api_server import api_server_start
|
|||||||
|
|
||||||
def test_index_redirect_logic():
|
def test_index_redirect_logic():
|
||||||
"""Test the redirect function logic directly."""
|
"""Test the redirect function logic directly."""
|
||||||
with api_server_start.app.test_request_context():
|
with api_server_start.app.test_client() as client:
|
||||||
response = api_server_start.index_redirect()
|
response = client.get("/", follow_redirects=False)
|
||||||
# In Flask, a redirect return object is a Response
|
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert response.headers['Location'] == '/docs'
|
assert response.location == '/docs'
|
||||||
|
|
||||||
|
|
||||||
def test_api_docs_logic():
|
def test_api_docs_logic():
|
||||||
"""Test that api_docs attempts to serve the correct file."""
|
"""Test that api_docs attempts to serve the correct file."""
|
||||||
with api_server_start.app.test_request_context():
|
with api_server_start.app.test_client() as client:
|
||||||
response = api_server_start.api_docs()
|
response = client.get("/docs")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.mimetype == 'text/html'
|
assert response.mimetype == "text/html"
|
||||||
# Manually join the chunks from the generator
|
response.direct_passthrough = False
|
||||||
data = b"".join(response.response)
|
data = response.get_data()
|
||||||
assert b'<!DOCTYPE html>' in data or b'<html>' in data
|
assert b"<!DOCTYPE html>" in data or b"<html>" in data
|
||||||
|
|||||||
Reference in New Issue
Block a user