From 6d0b30953a079d45a7b35f1646e6e1181be0229e Mon Sep 17 00:00:00 2001 From: Yun Xu Date: Mon, 15 Jan 2018 17:40:44 -0800 Subject: [PATCH] add unit test which should fail on original code --- tests/test_routes.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_routes.py b/tests/test_routes.py index 84d6b221..969128f8 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -907,3 +907,27 @@ def test_unicode_routes(): request, response = app.test_client.get('/overload/你好') assert response.text == 'OK2 你好' + + +def test_uri_with_different_method_and_different_params(): + app = Sanic('test_uri') + + @app.route('/ads/', methods=['GET']) + async def ad_get(request, ad_id): + return json({'ad_id': ad_id}) + + @app.route('/ads/', methods=['POST']) + async def ad_post(request, action): + return json({'action': action}) + + request, response = app.test_client.get('/ads/1234') + assert response.status == 200 + assert response.json == { + 'ad_id': '/ads/1234' + } + + request, response = app.test_client.post('/ads/post') + assert response.status == 200 + assert response.json == { + 'action': 'post' + }