diff --git a/sanic/views.py b/sanic/views.py index 2c4dcce2..980a5f74 100644 --- a/sanic/views.py +++ b/sanic/views.py @@ -1,7 +1,7 @@ from .exceptions import InvalidUsage -class MethodView: +class HTTPMethodView: """ Simple class based implementation of view for the sanic. You should implement methods(get, post, put, patch, delete) for the class to every HTTP method you want to support. diff --git a/tests/test_views.py b/tests/test_views.py index 251b7a10..59acb847 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,6 +1,6 @@ from sanic import Sanic from sanic.response import text, HTTPResponse -from sanic.views import MethodView +from sanic.views import HTTPMethodView from sanic.blueprints import Blueprint from sanic.request import Request from sanic.utils import sanic_endpoint_test @@ -9,21 +9,21 @@ from sanic.utils import sanic_endpoint_test def test_methods(): app = Sanic('test_methods') - class DummyView(MethodView): + class DummyView(HTTPMethodView): - def get(self, request, *args, **kwargs): + def get(self, request): return text('I am get method') - def post(self, request, *args, **kwargs): + def post(self, request): return text('I am post method') - def put(self, request, *args, **kwargs): + def put(self, request): return text('I am put method') - def patch(self, request, *args, **kwargs): + def patch(self, request): return text('I am patch method') - def delete(self, request, *args, **kwargs): + def delete(self, request): return text('I am delete method') app.add_route(DummyView(), '/') @@ -43,9 +43,9 @@ def test_methods(): def test_unexisting_methods(): app = Sanic('test_unexisting_methods') - class DummyView(MethodView): + class DummyView(HTTPMethodView): - def get(self, request, *args, **kwargs): + def get(self, request): return text('I am get method') app.add_route(DummyView(), '/') @@ -58,9 +58,9 @@ def test_unexisting_methods(): def test_argument_methods(): app = Sanic('test_argument_methods') - class DummyView(MethodView): + class DummyView(HTTPMethodView): - def get(self, request, my_param_here, *args, **kwargs): + def get(self, request, my_param_here): return text('I am get method with %s' % my_param_here) app.add_route(DummyView(), '/') @@ -74,9 +74,9 @@ def test_with_bp(): app = Sanic('test_with_bp') bp = Blueprint('test_text') - class DummyView(MethodView): + class DummyView(HTTPMethodView): - def get(self, request, *args, **kwargs): + def get(self, request): return text('I am get method') bp.add_route(DummyView(), '/') @@ -91,9 +91,9 @@ def test_with_bp_with_url_prefix(): app = Sanic('test_with_bp_with_url_prefix') bp = Blueprint('test_text', url_prefix='/test1') - class DummyView(MethodView): + class DummyView(HTTPMethodView): - def get(self, request, *args, **kwargs): + def get(self, request): return text('I am get method') bp.add_route(DummyView(), '/') @@ -107,9 +107,9 @@ def test_with_bp_with_url_prefix(): def test_with_middleware(): app = Sanic('test_with_middleware') - class DummyView(MethodView): + class DummyView(HTTPMethodView): - def get(self, request, *args, **kwargs): + def get(self, request): return text('I am get method') app.add_route(DummyView(), '/') @@ -140,9 +140,9 @@ def test_with_middleware_response(): results.append(request) results.append(response) - class DummyView(MethodView): + class DummyView(HTTPMethodView): - def get(self, request, *args, **kwargs): + def get(self, request): return text('I am get method') app.add_route(DummyView(), '/')