def setUp(self): super(WhenUsingTaskServer, self).setUp() # Queue target mocking setup. self.target = 'a target value here' queue_get_target_config = {'return_value': self.target} self.queue_get_target_patcher = mock.patch('barbican.queue.get_target', **queue_get_target_config) self.queue_get_target_mock = self.queue_get_target_patcher.start() # Queue server mocking setup. self.server_mock = mock.MagicMock() self.server_mock.start.return_value = None self.server_mock.stop.return_value = None queue_get_server_config = {'return_value': self.server_mock} self.queue_get_server_patcher = mock.patch('barbican.queue.get_server', **queue_get_server_config) self.queue_get_server_mock = self.queue_get_server_patcher.start() self.server = server.TaskServer() # Add an order to the in-memory database. self.external_id = 'keystone-id' project = database_utils.create_project(external_id=self.external_id) self.order = database_utils.create_order(project=project) self.request_id = 'request1234'
def setUp(self): super(WhenUsingTaskServer, self).setUp() # Queue target mocking setup. self.target = 'a target value here' queue_get_target_config = { 'return_value': self.target } self.queue_get_target_patcher = mock.patch( 'barbican.queue.get_target', **queue_get_target_config ) self.queue_get_target_mock = self.queue_get_target_patcher.start() # Queue server mocking setup. self.server_mock = mock.MagicMock() self.server_mock.start.return_value = None self.server_mock.stop.return_value = None queue_get_server_config = { 'return_value': self.server_mock } self.queue_get_server_patcher = mock.patch( 'barbican.queue.get_server', **queue_get_server_config ) self.queue_get_server_mock = self.queue_get_server_patcher.start() self.server = server.TaskServer() # Add an order to the in-memory database. self.external_id = 'keystone-id' project = database_utils.create_project( external_id=self.external_id) self.order = database_utils.create_order( project=project)
def setUp(self): super(WhenTestingSecretConsumerRepository, self).setUp() self.secret_repo = repositories.get_secret_repository() self.consumer_repo = repositories.get_secret_consumer_repository() self.session = self.consumer_repo.get_session() self.project = utils.create_project(session=self.session) self.secret = self._create_secret() self.session.commit()
def _create_retry_task(self, session, retry_at=None): project = database_utils.create_project(session=session) order = database_utils.create_order(project, session=session) order_retry_task = models.OrderRetryTask() order_retry_task.order_id = order.id order_retry_task.retry_task = u'retry-task' order_retry_task.retry_at = retry_at or self.date_time_now order_retry_task.retry_args = self.test_args order_retry_task.retry_kwargs = self.test_kwargs self.repo.create_from(order_retry_task, session=session) session.commit() return order_retry_task
def setUp(self): super(WhenCallingScheduleOrderRetryTasks, self).setUp() self.project = database_utils.create_project() self.order = database_utils.create_order(self.project) database_utils.get_session().commit() self.repo = repositories.OrderRetryTaskRepo() self.result = common.FollowOnProcessingStatusDTO() self.args = ['args-foo', 'args-bar'] self.kwargs = {'order_id': self.order.id, 'foo': 1, 'bar': 2} self.date_to_retry_at = ( datetime.datetime.utcnow() + datetime.timedelta(milliseconds=self.result.retry_msec))
def setUp(self): super(WhenCallingScheduleOrderRetryTasks, self).setUp() self.project = database_utils.create_project() self.order = database_utils.create_order(self.project) database_utils.get_session().commit() self.repo = repositories.OrderRetryTaskRepo() self.result = common.FollowOnProcessingStatusDTO() self.args = ['args-foo', 'args-bar'] self.kwargs = {'order_id': self.order.id, 'foo': 1, 'bar': 2} self.date_to_retry_at = ( datetime.datetime.utcnow() + datetime.timedelta( milliseconds=self.result.retry_msec) )
def project_wrapper(self, *args, **kwargs): project = utils.create_project(external_id=project_name) kwargs['project'] = project test_result = test_func(self, *args, **kwargs) project.delete() return test_result