From 6ce559d13d0eb25bf4aaf097e19cbc2eb66e05b6 Mon Sep 17 00:00:00 2001 From: Ivan Salamakha Date: Fri, 10 Nov 2017 15:30:47 +0200 Subject: [PATCH] Rename app name and fix test --- tests/test_routes.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/test_routes.py b/tests/test_routes.py index 0652f99a..23c5ca83 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -30,7 +30,8 @@ def test_versioned_routes_get(method): client_method = getattr(app.test_client, method) request, response = client_method('/v1/{}'.format(method)) - assert response.status== 200 + assert response.status == 200 + def test_shorthand_routes_get(): app = Sanic('test_shorhand_routes_get') @@ -45,6 +46,7 @@ def test_shorthand_routes_get(): request, response = app.test_client.post('/get') assert response.status == 405 + def test_shorthand_routes_multiple(): app = Sanic('test_shorthand_routes_multiple') @@ -63,6 +65,7 @@ def test_shorthand_routes_multiple(): request, response = app.test_client.options('/get/') assert response.status == 200 + def test_route_strict_slash(): app = Sanic('test_route_strict_slash') @@ -90,6 +93,7 @@ def test_route_strict_slash(): request, response = app.test_client.post('/post') assert response.status == 404 + def test_route_invalid_parameter_syntax(): with pytest.raises(ValueError): app = Sanic('test_route_invalid_param_syntax') @@ -100,6 +104,7 @@ def test_route_invalid_parameter_syntax(): request, response = app.test_client.get('/get') + def test_route_strict_slash_default_value(): app = Sanic('test_route_strict_slash', strict_slashes=True) @@ -110,6 +115,7 @@ def test_route_strict_slash_default_value(): request, response = app.test_client.get('/get/') assert response.status == 404 + def test_route_strict_slash_without_passing_default_value(): app = Sanic('test_route_strict_slash') @@ -120,6 +126,7 @@ def test_route_strict_slash_without_passing_default_value(): request, response = app.test_client.get('/get/') assert response.text == 'OK' + def test_route_strict_slash_default_value_can_be_overwritten(): app = Sanic('test_route_strict_slash', strict_slashes=True) @@ -130,6 +137,7 @@ def test_route_strict_slash_default_value_can_be_overwritten(): request, response = app.test_client.get('/get/') assert response.text == 'OK' + def test_route_optional_slash(): app = Sanic('test_route_optional_slash') @@ -143,6 +151,7 @@ def test_route_optional_slash(): request, response = app.test_client.get('/get/') assert response.text == 'OK' + def test_shorthand_routes_post(): app = Sanic('test_shorhand_routes_post') @@ -156,6 +165,7 @@ def test_shorthand_routes_post(): request, response = app.test_client.get('/post') assert response.status == 405 + def test_shorthand_routes_put(): app = Sanic('test_shorhand_routes_put') @@ -172,6 +182,7 @@ def test_shorthand_routes_put(): request, response = app.test_client.get('/put') assert response.status == 405 + def test_shorthand_routes_delete(): app = Sanic('test_shorhand_routes_delete') @@ -188,6 +199,7 @@ def test_shorthand_routes_delete(): request, response = app.test_client.get('/delete') assert response.status == 405 + def test_shorthand_routes_patch(): app = Sanic('test_shorhand_routes_patch') @@ -204,6 +216,7 @@ def test_shorthand_routes_patch(): request, response = app.test_client.get('/patch') assert response.status == 405 + def test_shorthand_routes_head(): app = Sanic('test_shorhand_routes_head') @@ -220,6 +233,7 @@ def test_shorthand_routes_head(): request, response = app.test_client.get('/head') assert response.status == 405 + def test_shorthand_routes_options(): app = Sanic('test_shorhand_routes_options') @@ -236,6 +250,7 @@ def test_shorthand_routes_options(): request, response = app.test_client.get('/options') assert response.status == 405 + def test_static_routes(): app = Sanic('test_dynamic_route') @@ -718,6 +733,7 @@ def test_remove_inexistent_route(): with pytest.raises(RouteDoesNotExist): app.remove_route('/test') + def test_removing_slash(): app = Sanic(__name__) @@ -836,7 +852,6 @@ def test_unmergeable_overload_routes(): request, response = app.test_client.post('/overload_whole') assert response.text == 'OK1' - @app.route('/overload_part', methods=['GET']) async def handler1(request): return text('OK1') @@ -859,15 +874,15 @@ def test_custom_route_converters(): custom_router = Router(converters={ "uuid": (uuid.UUID, regex) }) - app = Sanic('test_dynamic_route', router=custom_router) + app = Sanic('test_custom_route_converters', router=custom_router) results = [] - @app.route('/', methods=None) + @app.route('/') async def handler(request, id): results.append(id) return text('OK') - request, response = app.test_client.get('/folder/e010dcb8-6b40-11e7-8e04-0242ac120022') + request, response = app.test_client.get('/e010dcb8-6b40-11e7-8e04-0242ac120022') assert response.text == 'OK' assert isinstance(results[0], uuid.UUID)