Exemplo n.º 1
0
async def test_start_web_app(loop):
    """
        Check:
        - run web.Application with custom middlewares
        - import app routers
        - call close on delete
    """

    config.config['middlewares'] = [
        'aiohttp_boilerplate.middleware.defaults.cross_origin_rules',
    ]
    config.config['app_dir'] = 'tests'
    db_pool = dummy.DBPool()

    app = bootstrap.start_web_app(config.config, db_pool, loop)
    assert callable(app.middlewares[0])
    assert callable(app.on_cleanup[0])
    assert callable(app.on_shutdown[0])
Exemplo n.º 2
0
    async def get_application(self):
        """Override the get_app method to return your application.
        """
        # it's important to use the loop passed here.
        conf = await config.load_config()
        db_pool = await db.create_pool(
            conf=conf['postgres'],
            loop=self.loop,
        )

        app = start_web_app(
            conf=conf,
            db_pool=db_pool,
            loop=self.loop,
        )

        app.db_pool = db_pool
        self.conf = conf
        return app