-
-
Notifications
You must be signed in to change notification settings - Fork 336
Redirect from / to /docs #1477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect from / to /docs #1477
Conversation
📝 WalkthroughWalkthroughAdds a root Flask route ( Changes
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@test/api_endpoints/test_docs.py`:
- Line 1: The top-of-file comment contains an outdated path string "#
tests/test_root_redirect.py"; update or remove that comment so it correctly
reflects this file's purpose (e.g., replace with a relevant comment like "#
tests for docs API endpoints" or just delete the line). Locate the line with the
exact string "# tests/test_root_redirect.py" in the test file and change it
accordingly to avoid confusion.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@test/api_endpoints/test_docs.py`:
- Around line 7-13: The test_index_redirect_logic currently calls the view
function index_redirect() directly which bypasses Flask routing; change it to
use the Flask test client via api_server_start.app.test_client() and issue a GET
request to "/" so the full request cycle and routing are exercised; assert the
response status_code is 302 (or the expected redirect code) and that
response.headers['Location'] == '/docs' to verify the route wiring rather than
calling index_redirect() directly.
🧹 Nitpick comments (1)
test/api_endpoints/test_docs.py (1)
16-24: Improve consistency by usingtest_client()to exercise the actual/docsroute.The current test uses
test_request_context()and callsapi_docs()directly. However, all other tests in the codebase usetest_client()with HTTP method calls (e.g.,client.get()), which properly validates the route and integrates routing logic. Additionally,get_data()is the recommended way to read file responses fromsend_from_directory()in Flask tests, avoiding manual response iteration.Proposed refactor
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 + """Test that /docs serves HTML.""" + with api_server_start.app.test_client() as client: + response = client.get("/docs") + assert response.status_code == 200 + assert response.mimetype == "text/html" + response.direct_passthrough = False + data = response.get_data() + assert b"<!DOCTYPE html>" in data or b"<html>" in data
📌 Description
Implemented a friendly redirect from the root path (
/) to the API documentation (/docs) to improve user experience for browser-based access. Additionally, added unit tests for both the redirect logic and the documentation serving endpoint.🔍 Related Issues
📋 Type of Change
📷 Screenshots or Logs (if applicable)
✅ Checklist
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.