test: stabilize route assertions for FastAPI 0.137#8783
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the FastAPI dashboard tests by introducing a helper function _path_for to resolve route paths by their registered names. It updates test_v1_openapi_alias_websocket_routes_are_mounted and test_dashboard_config_aliases_are_registered_on_fastapi to use this helper, which simplifies the assertions and ensures route names are correctly configured. Additionally, a long assertion in test_astrbot_web_request_proxy_exposes_typed_methods was reformatted for readability. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
zouyonghe
left a comment
There was a problem hiding this comment.
Reviewed. This is a focused test-only compatibility fix and uses FastAPI public url_path_for API instead of inspecting router internals that changed in FastAPI 0.137. CI is green, and this also explains the unrelated full pytest failures on other open PRs.
The current dependency range allows FastAPI 0.137.0 / Starlette 1.3.1 in CI. With that stack, these two route-registration tests can fail because they inspect
app.router.routesinternals directly: FastAPI now keeps included routers behind_IncludedRouter, which has nopathattribute and can hide routes from the flat list.The routes themselves are still registered and resolvable through FastAPI's public
url_path_for()API, so this keeps the tests focused on the intended behavior: the expected aliases are mounted at the expected paths.Modifications / 改动点
Assert the route aliases through
app.url_path_for()instead of scanning route object class names /pathattributes directly.Keep the change limited to
tests/test_fastapi_v1_dashboard.py.This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Verification run locally:
The
uv runenvironment resolved the same relevant versions seen in CI:Both pytest runs passed:
Checklist / 检查清单
requirements.txtandpyproject.toml.Summary by Sourcery
Stabilize FastAPI v1 dashboard tests against internal routing changes by asserting routes via FastAPI’s public URL resolution API.
Tests: