From 46934f20aef34cf8fc3faea952d3007d5599cf0b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 23 2019 13:49:44 +0000 Subject: Move settings all the routes in a dedicate function This way it can be re-used in the tests. Signed-off-by: Pierre-Yves Chibon --- diff --git a/mdapi/__init__.py b/mdapi/__init__.py index 3c56044..df70827 100644 --- a/mdapi/__init__.py +++ b/mdapi/__init__.py @@ -427,12 +427,7 @@ def index(request): charset='utf-8') -@asyncio.coroutine -def init(loop): - logging.basicConfig() - logging.config.dictConfig(CONFIG.get('LOGGING') or {'version': 1}) - - app = web.Application(loop=loop) +def _set_routes(app): routes = [] prefix = CONFIG.get('PREFIX', '') if prefix: @@ -459,6 +454,16 @@ def init(loop): ]) for route in routes: app.router.add_route('GET', prefix + route[0], route[1]) + return app + + +@asyncio.coroutine +def init(loop): + logging.basicConfig() + logging.config.dictConfig(CONFIG.get('LOGGING') or {'version': 1}) + + app = web.Application(loop=loop) + app = _set_routes(app) srv = yield from loop.create_server( app.make_handler(),