def test_base_path_is_removed_before_routing(self):
"""Test that RemoveBasePathMiddleware is executed before routing"""
app = falcon.API(middleware=RemoveBasePathMiddleware())
# We dont include /base_path as it will be removed in middleware
app.add_route('/sub_path', MiddlewareClassResource())
client = testing.TestClient(app)
response = client.simulate_request(path='/base_path/sub_path')
assert _EXPECTED_BODY == response.json
assert response.status == falcon.HTTP_200
response = client.simulate_request(path='/base_pathIncorrect/sub_path')
assert response.status == falcon.HTTP_404
评论列表
文章目录