Add test for method not allow situation

This commit is contained in:
chhsiao90 2016-10-23 21:58:57 +08:00
parent 201e232a0d
commit 9051e985a0

View File

@ -164,3 +164,17 @@ def test_route_duplicate():
@app.route('/test/<dynamic>/') @app.route('/test/<dynamic>/')
async def handler2(request, dynamic): async def handler2(request, dynamic):
pass pass
def test_method_not_allowed():
app = Sanic('test_method_not_allowed')
@app.route('/test', methods=['GET'])
async def handler(request):
return text('OK')
request, response = sanic_endpoint_test(app, uri='/test')
assert response.status == 200
request, response = sanic_endpoint_test(app, method='post', uri='/test')
assert response.status == 405