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 tests environment """ container.reset() self.uaa_service = AsyncMock(spec=UaaService) container.set('uaa_service', self.uaa_service)
async def get_application(self): """ Override the get_app method to return the mocked application. """ container.reset() container.set('apm', Mock(spec=Client)) app = Application() return app
async def test_healthcheck(self, health_check_mock): """ Test the app healthcheck method """ container.reset() engine_mock = Mock(spec=Engine) container.set('storage_engine', engine_mock) health = await health_check() self.assertTrue(health) health_check_mock.assert_called_with(engine_mock)
def setUp(self) -> None: """ Set up the test environment """ container.reset() self.apm_mock = Mock(spec=Client) container.set('apm', self.apm_mock) app = Application() self.app = app
async def get_application(self): """ Get base web application for tests """ container.reset() container.set('apm', Mock(spec=Client)) self.mocked_news_service = Mock(spec=NewsService) container.set('news_service', self.mocked_news_service) app = Application() app.middlewares.append(error_middleware) app.middlewares.append(mock_auth_middleware) setup_routes(app) return app
def setUp(self, consumer_mock, process_mock): """ Initialize the consumer service mocking necessary properties """ self.apm_mock = Mock(spec=Client) container.reset() container.set('apm', self.apm_mock) self.consumer_mock = consumer_mock self.process_mock = process_mock self.news_service_mock = Mock(spec=NewsService) self.nlp_service_mock = Mock(spec=NlpServiceService) self.app = Application() self.consumer_mock.test_connection.return_value = True self.news_consume_service = NewsConsumeService(self.news_service_mock, self.nlp_service_mock)
def setUpClass(cls) -> None: container.reset() container.set('apm', Mock(spec=Client)) mock_auth_service = Mock(spec=AuthService) async def mock_auth_response(): return dict(token='test_token') async def mock_validate_token_response(): return dict(id=1, username='******') mock_auth_service.authenticate.return_value = mock_auth_response() mock_auth_service.validate_token.return_value = mock_validate_token_response( ) container.set('auth_service', mock_auth_service)
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 setUp(self) -> None: container.reset() self.news_service_mock = Mock(spec=NewsService) container.set('news_service', self.news_service_mock)