def init_uaa(app: Application) -> Application: """ Initialize the web application Args: app: configuration profile to use Returns: web application initialized """ load() setup_event_bus() ElasticAPM(app, container.get('apm')) storage_engine: Engine = container.get('storage_engine') init_sql_db(BASE, storage_engine, alembic_ini_path=ALEMBIC_INI_PATH) if not sql_health_check(storage_engine): sys.exit(1) HealthCheck(app, health_check) users_view.setup_routes(app) auth_view.setup_routes(app) app.middlewares.append(error_middleware) app.middlewares.append(auth_middleware) app.middlewares.append(validation_middleware) return app
def setUp(self) -> None: """ Set up the test environment creating the database engine """ container.reset() test_engine = create_sql_engine(SqlEngineType.SQLITE) self.session_provider = SqlSessionProvider(test_engine) BASE.query = self.session_provider.query_property init_sql_db(BASE, test_engine) named_entity_type_service = NamedEntityTypeService(session_provider=self.session_provider) named_entity_service = NamedEntityService(session_provider=self.session_provider) named_entity_type = asyncio.run(named_entity_type_service.save(name='TEST')) asyncio.run(named_entity_service.save(value=self.TEST_ENTITY_1, named_entity_type_id=named_entity_type.id)) asyncio.run(named_entity_service.save(value=self.TEST_ENTITY_2, named_entity_type_id=named_entity_type.id)) noun_chunks_service = NounChunkService(session_provider=self.session_provider) asyncio.run(noun_chunks_service.save(value=self.TEST_NOUN_CHUNK_1)) asyncio.run(noun_chunks_service.save(value=self.TEST_NOUN_CHUNK_2)) asyncio.run(noun_chunks_service.save(value=self.TEST_NOUN_CHUNK_3)) self.newspaper_service = NewspaperService(session_provider=self.session_provider) app = Application() container.set('session_provider', self.session_provider) container.set('named_entity_service', named_entity_service) container.set('noun_chunk_service', noun_chunks_service) container.set('newspaper_service', self.newspaper_service) self.app = app
def setUp(self) -> None: """ Set up the test environment creating the database engine """ test_engine = create_sql_engine(SqlEngineType.SQLITE) self.session_provider = SqlSessionProvider(test_engine) BASE.query = self.session_provider.query_property init_sql_db(BASE, test_engine)
def setUp(self) -> None: """ Set up the test environment creating the database engine """ container.reset() test_engine = create_sql_engine(SqlEngineType.SQLITE) self.session_provider = SqlSessionProvider(test_engine) BASE.query = self.session_provider.query_property init_sql_db(BASE, test_engine) self.user_service = UserService(session_provider=self.session_provider) self.source_service = SourceService(session_provider=self.session_provider) app = Application() container.set('session_provider', self.session_provider) container.set('source_service', self.source_service) container.set('user_service', self.user_service) self.app = app
def setUp(self, consumer_mock, process_mock, create_engine_mock) -> None: container.reset() self.apm_mock = Mock(spec=Client) container.set('apm', self.apm_mock) self.consumer_mock = consumer_mock self.process_mock = process_mock self.app = Application() test_engine = create_sql_engine(SqlEngineType.SQLITE) init_sql_db(BASE, test_engine) self.session_provider = SqlSessionProvider(test_engine) create_engine_mock.return_value = test_engine self.source_service = SourceService(self.session_provider) self.news_service = NewService(self.session_provider) self.named_entity_service = NamedEntityService(self.session_provider) self.named_entity_type_service = NamedEntityTypeService( self.session_provider) self.index_service = IndexService()
def init_search_engine(app: Application) -> Application: """ Initialize the web application Args: app: configuration profile to use Returns: web application initialized """ load() ElasticAPM(app, container.get('apm')) storage_engine = container.get('storage_engine') if not sql_health_check(storage_engine): sys.exit(1) init_sql_db(BASE, storage_engine, alembic_ini_path=ALEMBIC_INI_PATH) session_provider = container.get('session_provider') BASE.query = session_provider.query_property HealthCheck(app, health_check) container.get('index_service') setup_event_bus() setup_graphql_routes(app, schema, get_logger(), middlewares=[SQLMiddleware(session_provider)]) index_views.setup_routes(app) app.middlewares.append(error_middleware) app.middlewares.append(uaa_auth_middleware) app.middlewares.append(validation_middleware) app.on_shutdown.append(shutdown) return app