Merge pull request #100 from chhsiao90/test-router

Add test for method not allow situation
This commit is contained in:
Channel Cat 2016-10-23 21:15:31 -07:00 committed by GitHub
commit 12e900e8f9

View File

@ -164,3 +164,17 @@ def test_route_duplicate():
@app.route('/test/<dynamic>/')
async def handler2(request, dynamic):
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