unit tests

This commit is contained in:
Yun Xu 2017-06-08 17:25:22 -07:00
parent 81889fd7a3
commit 3802f8ff65

View File

@ -197,16 +197,18 @@ def test_content_type():
@app.route('/') @app.route('/')
async def handler(request): async def handler(request):
return text('OK') return text(request.content_type)
request, response = app.test_client.get('/') request, response = app.test_client.get('/')
assert request.content_type == DEFAULT_HTTP_CONTENT_TYPE assert request.content_type == DEFAULT_HTTP_CONTENT_TYPE
assert response.text == DEFAULT_HTTP_CONTENT_TYPE
headers = { headers = {
'content-type': 'application/json', 'content-type': 'application/json',
} }
request, response = app.test_client.get('/', headers=headers) request, response = app.test_client.get('/', headers=headers)
assert request.content_type == 'application/json' assert request.content_type == 'application/json'
assert response.text == 'application/json'
# ------------------------------------------------------------ # # ------------------------------------------------------------ #