-
Notifications
You must be signed in to change notification settings - Fork 43
Fix test failures from starlette 0.49.1 upgrade #1083
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
| import json | ||
| import unittest | ||
|
|
||
| from fastapi import HTTPException | ||
| from fastapi import FastAPI | ||
| from fastapi.testclient import TestClient | ||
|
|
||
| from ssvc.api.v1.routers import decision_table | ||
|
|
@@ -30,7 +30,9 @@ | |
|
|
||
| class TestDecisionPointAPI(unittest.TestCase): | ||
| def setUp(self): | ||
| self.client = TestClient(decision_table.router) | ||
| app = FastAPI() | ||
| app.include_router(decision_table.router) | ||
| self.client = TestClient(app) | ||
|
Comment on lines
31
to
+35
|
||
|
|
||
| # create a new registry for testing | ||
| self.r = SsvcObjectRegistry( | ||
|
|
@@ -110,8 +112,8 @@ def test_get_decision_point_by_id_success(self): | |
| self.assertEqual(expected, response.json()) | ||
|
|
||
| def test_get_decision_point_by_id_bad_id(self): | ||
| with self.assertRaises(HTTPException): | ||
| self.client.get("/decision_table?id=bad_id_format") | ||
| response = self.client.get("/decision_table?id=bad_id_format") | ||
| self.assertEqual(400, response.status_code) | ||
|
Comment on lines
+115
to
+116
|
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
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.
This request path omits the trailing slash for a route declared at
@router.get("/")under the/decision_pointprefix. The test currently relies on FastAPI/Starlette's redirect-slashes behavior (and the client following redirects), which can make the test brittle. Use/decision_point/?id=bad_id_formatto hit the route directly.