Skip to content

Commit 666a6b1

Browse files
committed
[IMP]fastapi: add test for multi-slash scenario
1 parent 55adbd2 commit 666a6b1

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

fastapi/demo/fastapi_endpoint_demo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ methods. See documentation to learn more about how to create a new app.
5151
Like the other demo endpoint but with multi-slash
5252
</field>
5353
<field name="app">demo</field>
54-
<field name="root_path">/fastapi/demo</field>
54+
<field name="root_path">/fastapi/demo-multi</field>
5555
<field name="demo_auth_method">http_basic</field>
5656
<field name="user_id" ref="my_demo_app_user" />
5757
</record>

fastapi/tests/test_fastapi.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ class FastAPIHttpCase(HttpCase):
2020
def setUpClass(cls):
2121
super().setUpClass()
2222
cls.fastapi_demo_app = cls.env.ref("fastapi.fastapi_endpoint_demo")
23-
cls.fastapi_demo_app._handle_registry_sync()
23+
cls.fastapi_multi_demo_app = cls.env.ref(
24+
"fastapi.fastapi_endpoint_multislash_demo"
25+
)
26+
cls.fastapi_apps = cls.fastapi_demo_app + cls.fastapi_multi_demo_app
27+
cls.fastapi_apps._handle_registry_sync()
2428
lang = (
2529
cls.env["res.lang"]
2630
.with_context(active_test=False)
@@ -189,3 +193,9 @@ def test_url_matching(self):
189193
EndPoint._find_first_matching_url_path(paths, "/fastapi/v1/test"),
190194
"/fastapi/v1",
191195
)
196+
197+
def test_multi_slash(self):
198+
route = "/fastapi/demo-multi/demo/"
199+
response = self.url_open(route, timeout=20)
200+
self.assertEqual(response.status_code, 200)
201+
self.assertIn(self.fastapi_multi_demo_app.root_path, str(response.url))

0 commit comments

Comments
 (0)