def step_impl_prepare_for_tests(context, service_type): """Prepare bdd tests to run against either mock or real external services.""" step_impl_reset_db(context) with context.app.app_context(): context.bdd_helper = SecureMessagingContextHelper() if service_type.lower() == 'real': party.use_real_service() internal_user_service.use_real_service() else: party.use_mock_service() internal_user_service.use_mock_service()
def setUp(self): """setup test environment""" self.json_message = { 'msg_to': ['Tej'], 'msg_from': 'Gemma', 'subject': 'MyMessage', 'body': 'hello', 'thread_id': "", 'business_id': "7fc0e8ab-189c-4794-b8f4-9f05a1db185b", 'survey': "RSI" } self.now = datetime.now(timezone.utc) internal_user_service.use_mock_service() party.use_mock_service() self.app = create_app()
def setUp(self): """setup test environment""" self.app = application.create_app() self.client = self.app.test_client() self.engine = create_engine(self.app.config['SQLALCHEMY_DATABASE_URI']) internal_token_data = {constants.USER_IDENTIFIER: AppTestCase.SPECIFIC_INTERNAL_USER, "role": "internal"} external_token_data = {constants.USER_IDENTIFIER: AppTestCase.SPECIFIC_EXTERNAL_USER, "role": "respondent", "claims": [{'business_id': 'f1a5e99c-8edf-489a-9c72-6cabe6c387fc', 'surveys': [AppTestCase.BRES_SURVEY] }] } with self.app.app_context(): internal_signed_jwt = encode(internal_token_data) external_signed_jwt = encode(external_token_data) self.internal_user_header = {'Content-Type': 'application/json', 'Authorization': internal_signed_jwt} self.external_user_header = {'Content-Type': 'application/json', 'Authorization': external_signed_jwt} self.test_message = {'msg_to': ['0a7ad740-10d5-4ecb-b7ca-3c0384afb882'], 'msg_from': AppTestCase.SPECIFIC_INTERNAL_USER, 'subject': 'MyMessage', 'body': 'hello', 'thread_id': "", 'collection_case': 'ACollectionCase', 'collection_exercise': 'ACollectionExercise', 'business_id': 'f1a5e99c-8edf-489a-9c72-6cabe6c387fc', 'survey': self.BRES_SURVEY} with self.app.app_context(): database.db.init_app(current_app) database.db.drop_all() database.db.create_all() self.db = database.db party.use_mock_service() internal_user_service.use_mock_service()
def setUp(self): """setup test environment""" self.app = create_app() self.app.testing = True self.engine = create_engine(self.app.config['SQLALCHEMY_DATABASE_URI']) self.MESSAGE_LIST_ENDPOINT = "http://localhost:5050/messages" self.MESSAGE_BY_ID_ENDPOINT = "http://localhost:5050/message/" with self.app.app_context(): database.db.init_app(current_app) database.db.drop_all() database.db.create_all() self.db = database.db self.user_internal = User( RetrieverTestCaseHelper.default_internal_actor, 'internal') self.second_user_internal = User( RetrieverTestCaseHelper.second_internal_actor, 'internal') self.user_respondent = User( RetrieverTestCaseHelper.default_external_actor, 'respondent') self.second_user_respondent = User( RetrieverTestCaseHelper.second_external_actor, 'respondent') party.use_mock_service()
def setUp(self): """setup test environment""" self.app = create_app() self.app.testing = True party.use_mock_service() internal_user_service.use_mock_service()
def setUp(self): self.app = create_app() self.client = self.app.test_client() internal_user_service.use_mock_service() party.use_mock_service()
def step_impl_use_mock_party_service(context): """Use mock party service tests.""" party.use_mock_service()
def setUp(self): """setup test environment""" self.now = datetime.now(timezone.utc) internal_user_service.use_mock_service() party.use_mock_service()