Add tests (#1433)
* Add tests for remove_route() * Add tests for sanic/router.py * Add tests for sanic/cookies.py * Disable reset logging in test_logging.py * Add tests for sanic/request.py * Add tests for ContentRangeHandler * Add tests for exception at response middleware * Fix cached_handlers for ErrorHandler.lookup() * Add test for websocket request timeout * Add tests for getting cookies of StreamResponse, Remove some unused variables in tests/test_cookies.py * Add tests for nested error handle
This commit is contained in:
@@ -264,6 +264,29 @@ def test_stream_response_writes_correct_content_to_transport(streaming_app):
|
||||
streaming_app.run(host=HOST, port=PORT)
|
||||
|
||||
|
||||
def test_stream_response_with_cookies(app):
|
||||
|
||||
@app.route("/")
|
||||
async def test(request):
|
||||
response = stream(sample_streaming_fn, content_type='text/csv')
|
||||
response.cookies['test'] = 'modified'
|
||||
response.cookies['test'] = 'pass'
|
||||
return response
|
||||
|
||||
request, response = app.test_client.get('/')
|
||||
assert response.cookies['test'].value == 'pass'
|
||||
|
||||
|
||||
def test_stream_response_without_cookies(app):
|
||||
|
||||
@app.route("/")
|
||||
async def test(request):
|
||||
return stream(sample_streaming_fn, content_type='text/csv')
|
||||
|
||||
request, response = app.test_client.get('/')
|
||||
assert response.cookies == {}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def static_file_directory():
|
||||
"""The static directory to serve"""
|
||||
@@ -451,6 +474,7 @@ def test_file_stream_response_range(app, file_name, static_file_directory, size,
|
||||
assert 'Content-Range' in response.headers
|
||||
assert response.headers['Content-Range'] == 'bytes {}-{}/{}'.format(range.start, range.end, range.total)
|
||||
|
||||
|
||||
def test_raw_response(app):
|
||||
|
||||
@app.get('/test')
|
||||
|
||||
Reference in New Issue
Block a user