ccd4c9615c
Update all tests to be compatible with requests-async Cleanup testing client changes with black and isort Remove Python 3.5 and other meta doc cleanup rename pyproject and fix pep517 error Add black config to tox.ini Cleanup tests and remove aiohttp tox.ini change for easier development commands Remove aiohttp from changelog and requirements Cleanup imports and Makefile
87 lines
2.2 KiB
Python
87 lines
2.2 KiB
Python
import asyncio
|
|
import logging
|
|
|
|
from sanic.config import BASE_LOGO
|
|
|
|
|
|
try:
|
|
import uvloop # noqa
|
|
|
|
ROW = 0
|
|
except BaseException:
|
|
ROW = 1
|
|
|
|
|
|
def test_logo_base(app, caplog):
|
|
server = app.create_server(debug=True, return_asyncio_server=True)
|
|
loop = asyncio.new_event_loop()
|
|
asyncio.set_event_loop(loop)
|
|
loop._stopping = False
|
|
|
|
with caplog.at_level(logging.DEBUG):
|
|
_server = loop.run_until_complete(server)
|
|
|
|
_server.close()
|
|
loop.run_until_complete(_server.wait_closed())
|
|
app.stop()
|
|
|
|
assert caplog.record_tuples[ROW][1] == logging.DEBUG
|
|
assert caplog.record_tuples[ROW][2] == BASE_LOGO
|
|
|
|
|
|
def test_logo_false(app, caplog):
|
|
app.config.LOGO = False
|
|
|
|
server = app.create_server(debug=True, return_asyncio_server=True)
|
|
loop = asyncio.new_event_loop()
|
|
asyncio.set_event_loop(loop)
|
|
loop._stopping = False
|
|
|
|
with caplog.at_level(logging.DEBUG):
|
|
_server = loop.run_until_complete(server)
|
|
|
|
_server.close()
|
|
loop.run_until_complete(_server.wait_closed())
|
|
app.stop()
|
|
|
|
assert caplog.record_tuples[ROW][1] == logging.INFO
|
|
assert caplog.record_tuples[ROW][2] == "Goin' Fast @ http://127.0.0.1:8000"
|
|
|
|
|
|
def test_logo_true(app, caplog):
|
|
app.config.LOGO = True
|
|
|
|
server = app.create_server(debug=True, return_asyncio_server=True)
|
|
loop = asyncio.new_event_loop()
|
|
asyncio.set_event_loop(loop)
|
|
loop._stopping = False
|
|
|
|
with caplog.at_level(logging.DEBUG):
|
|
_server = loop.run_until_complete(server)
|
|
|
|
_server.close()
|
|
loop.run_until_complete(_server.wait_closed())
|
|
app.stop()
|
|
|
|
assert caplog.record_tuples[ROW][1] == logging.DEBUG
|
|
assert caplog.record_tuples[ROW][2] == BASE_LOGO
|
|
|
|
|
|
def test_logo_custom(app, caplog):
|
|
app.config.LOGO = "My Custom Logo"
|
|
|
|
server = app.create_server(debug=True, return_asyncio_server=True)
|
|
loop = asyncio.new_event_loop()
|
|
asyncio.set_event_loop(loop)
|
|
loop._stopping = False
|
|
|
|
with caplog.at_level(logging.DEBUG):
|
|
_server = loop.run_until_complete(server)
|
|
|
|
_server.close()
|
|
loop.run_until_complete(_server.wait_closed())
|
|
app.stop()
|
|
|
|
assert caplog.record_tuples[ROW][1] == logging.DEBUG
|
|
assert caplog.record_tuples[ROW][2] == "My Custom Logo"
|