2018-12-30 11:18:06 +00:00
|
|
|
import asyncio
|
2019-04-23 22:44:42 +01:00
|
|
|
import logging
|
2018-12-30 11:18:06 +00:00
|
|
|
|
2021-01-28 07:22:22 +00:00
|
|
|
from sanic_testing.testing import PORT
|
2019-04-23 22:44:42 +01:00
|
|
|
|
2021-01-28 07:22:22 +00:00
|
|
|
from sanic.config import BASE_LOGO
|
2018-12-30 12:07:21 +00:00
|
|
|
|
2018-12-30 11:18:06 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
def test_logo_base(app, run_startup):
|
|
|
|
logs = run_startup(app)
|
2018-12-30 11:18:06 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
assert logs[0][1] == logging.DEBUG
|
|
|
|
assert logs[0][2] == BASE_LOGO
|
2018-12-30 11:46:08 +00:00
|
|
|
|
2018-12-30 11:18:06 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
def test_logo_false(app, caplog, run_startup):
|
2018-12-30 11:18:06 +00:00
|
|
|
app.config.LOGO = False
|
2018-12-30 11:46:08 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
logs = run_startup(app)
|
2018-12-30 11:18:06 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
banner, port = logs[0][2].rsplit(":", 1)
|
|
|
|
assert logs[0][1] == logging.INFO
|
2020-03-26 04:42:46 +00:00
|
|
|
assert banner == "Goin' Fast @ http://127.0.0.1"
|
|
|
|
assert int(port) > 0
|
2018-12-30 11:18:06 +00:00
|
|
|
|
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
def test_logo_true(app, run_startup):
|
2018-12-30 11:18:06 +00:00
|
|
|
app.config.LOGO = True
|
2018-12-30 11:46:08 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
logs = run_startup(app)
|
2018-12-30 11:46:08 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
assert logs[0][1] == logging.DEBUG
|
|
|
|
assert logs[0][2] == BASE_LOGO
|
2018-12-30 11:46:08 +00:00
|
|
|
|
2018-12-30 11:18:06 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
def test_logo_custom(app, run_startup):
|
2018-12-30 11:18:06 +00:00
|
|
|
app.config.LOGO = "My Custom Logo"
|
2018-12-30 11:46:08 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
logs = run_startup(app)
|
2018-12-30 11:18:06 +00:00
|
|
|
|
2021-08-05 20:55:42 +01:00
|
|
|
assert logs[0][1] == logging.DEBUG
|
|
|
|
assert logs[0][2] == "My Custom Logo"
|