def client(loop, aiohttp_client, app_cfg, postgres_db, qx_client_outdir, mocks_on_projects_api): cfg = deepcopy(app_cfg) cfg["projects"]["enabled"] = True cfg["storage"]["enabled"] = False cfg["rabbit"]["enabled"] = False cfg["main"]["client_outdir"] = qx_client_outdir app = create_safe_application(cfg) setup_settings(app) setup_statics(app) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) # TODO: why should we need this?? setup_login(app) setup_users(app) setup_products(app) assert setup_projects(app), "Shall not skip this setup" assert setup_studies_access(app), "Shall not skip this setup" # server and client yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": cfg["main"]["port"], "host": cfg["main"]["host"] }, ))
def client(loop, aiohttp_unused_port, aiohttp_client, api_version_prefix): app = create_safe_application() MAX_DELAY_SECS_ALLOWED = 1 # secs async def slow_handler(request: web.Request): import time time.sleep(MAX_DELAY_SECS_ALLOWED * 1.1) raise web.HTTPOk() server_kwargs = {"port": aiohttp_unused_port(), "host": "localhost"} # fake config app[APP_CONFIG_KEY] = { "main": server_kwargs, "rest": { "enabled": True, "version": api_version_prefix }, } # activates only security+restAPI sub-modules setup_settings(app) setup_security(app) setup_rest(app) app.router.add_get("/slow", slow_handler) cli = loop.run_until_complete( aiohttp_client(app, server_kwargs=server_kwargs)) return cli
def settings(monkeypatch) -> ApplicationSettings: monkeypatch.setenv("SC_VCS_URL", "[email protected]:ITISFoundation/osparc-simcore.git") monkeypatch.setenv("SWARM_STACK_NAME", "simcore_stack") monkeypatch.setenv("STACK_NAME", "invalid_env") monkeypatch.setenv("WEBSERVER_MANUAL_MAIN_URL", "http://some_doc.org") app = dict() # init and validation happens here setup_settings(app) assert APP_SETTINGS_KEY in app return app[APP_SETTINGS_KEY]