rework testing

This commit is contained in:
Suby Raman
2017-02-14 14:51:20 -05:00
parent 51611c3934
commit 3b68dc72e7
27 changed files with 387 additions and 342 deletions

View File

@@ -2,7 +2,6 @@ from json import loads as json_loads, dumps as json_dumps
from sanic import Sanic
from sanic.request import Request
from sanic.response import json, text, HTTPResponse
from sanic.utils import sanic_endpoint_test
# ------------------------------------------------------------ #
@@ -22,7 +21,7 @@ def test_middleware_request():
async def handler(request):
return text('OK')
request, response = sanic_endpoint_test(app)
request, response = app.test_client.get('/')
assert response.text == 'OK'
assert type(results[0]) is Request
@@ -46,7 +45,7 @@ def test_middleware_response():
async def handler(request):
return text('OK')
request, response = sanic_endpoint_test(app)
request, response = app.test_client.get('/')
assert response.text == 'OK'
assert type(results[0]) is Request
@@ -65,7 +64,7 @@ def test_middleware_override_request():
async def handler(request):
return text('FAIL')
response = sanic_endpoint_test(app, gather_request=False)
response = app.test_client.get('/', gather_request=False)
assert response.status == 200
assert response.text == 'OK'
@@ -82,7 +81,7 @@ def test_middleware_override_response():
async def handler(request):
return text('FAIL')
request, response = sanic_endpoint_test(app)
request, response = app.test_client.get('/')
assert response.status == 200
assert response.text == 'OK'
@@ -122,7 +121,7 @@ def test_middleware_order():
async def handler(request):
return text('OK')
request, response = sanic_endpoint_test(app)
request, response = app.test_client.get('/')
assert response.status == 200
assert order == [1,2,3,4,5,6]