def client(loop, aiohttp_unused_port, aiohttp_client, python27_path, postgres_service, minio_service, osparc_api_specs_dir): app = web.Application() main_cfg = { 'port': aiohttp_unused_port(), 'host': 'localhost', 'python2': python27_path, "max_workers": 4 } rest_cfg = { 'oas_repo': str(osparc_api_specs_dir ), #'${OSPARC_SIMCORE_REPO_ROOTDIR}/api/specs', #oas_repo: http://localhost:8043/api/specs } postgres_cfg = postgres_service s3_cfg = minio_service # fake config app[APP_CONFIG_KEY] = { 'main': main_cfg, 'postgres': postgres_cfg, 's3': s3_cfg, 'rest': rest_cfg } #app.middlewares.append(dsm_middleware) setup_db(app) setup_rest(app) setup_dsm(app) setup_s3(app) cli = loop.run_until_complete(aiohttp_client(app, server_kwargs=main_cfg)) return cli
def client( loop, aiohttp_unused_port, aiohttp_client, postgres_service, minio_service, osparc_api_specs_dir, ): app = web.Application() api_token = os.environ.get("BF_API_KEY", "none") api_secret = os.environ.get("BF_API_SECRET", "none") main_cfg = { "port": aiohttp_unused_port(), "host": "localhost", "max_workers": 4, "testing": True, "test_datcore": { "api_token": api_token, "api_secret": api_secret }, } rest_cfg = { "oas_repo": str(osparc_api_specs_dir ), #'${OSPARC_SIMCORE_REPO_ROOTDIR}/api/specs', # oas_repo: http://localhost:8043/api/specs } postgres_cfg = postgres_service s3_cfg = minio_service # fake config app[APP_CONFIG_KEY] = { "main": main_cfg, "postgres": postgres_cfg, "s3": s3_cfg, "rest": rest_cfg, } setup_db(app) setup_rest(app) setup_dsm(app) setup_s3(app) cli = loop.run_until_complete(aiohttp_client(app, server_kwargs=main_cfg)) return cli
def client( loop, aiohttp_unused_port, aiohttp_client: TestClient, postgres_service, postgres_service_url, minio_service, osparc_api_specs_dir, monkeypatch, ): app = web.Application() # FIXME: postgres_service fixture environs different from project_env_devel_environment. Do it after https://github.com/ITISFoundation/osparc-simcore/pull/2276 resolved pg_config = postgres_service.copy() pg_config.pop("database") for key, value in pg_config.items(): monkeypatch.setenv(f"POSTGRES_{key.upper()}", f"{value}") for key, value in minio_service.items(): monkeypatch.setenv(f"S3_{key.upper()}", f"{value}") monkeypatch.setenv("STORAGE_PORT", str(aiohttp_unused_port())) monkeypatch.setenv("STORAGE_LOG_LEVEL", "DEBUG") monkeypatch.setenv("STORAGE_TESTING", "1") monkeypatch.setenv("SC_BOOT_MODE", "local-development") settings = Settings.create_from_envs() print(settings.json(indent=2)) app[APP_CONFIG_KEY] = settings setup_db(app) setup_rest(app) setup_dsm(app) setup_s3(app) cli = loop.run_until_complete( aiohttp_client( app, server_kwargs={"port": settings.STORAGE_PORT, "host": "localhost"} ) ) return cli