Ejemplo n.º 1
0
 def test_execute_no_task(self, mock_get_task):
     mock_get_task.return_value = None
     complete = import_flow._CompleteTask(TASK_ID1, TASK_TYPE,
                                          self.task_repo, self.wrapper)
     complete.execute()
     self.task_repo.save.assert_not_called()
     self.wrapper.drop_lock_for_task.assert_called_once_with()
Ejemplo n.º 2
0
 def test_execute(self, mock_get_task):
     complete = import_flow._CompleteTask(TASK_ID1, TASK_TYPE,
                                          self.task_repo, self.wrapper)
     mock_get_task.return_value = self.task
     complete.execute()
     mock_get_task.assert_called_once_with(self.task_repo, TASK_ID1)
     self.task.succeed.assert_called_once_with({'image_id': IMAGE_ID1})
     self.task_repo.save.assert_called_once_with(self.task)
     self.wrapper.drop_lock_for_task.assert_called_once_with()
Ejemplo n.º 3
0
 def test_execute_succeed_fails(self, mock_get_task):
     mock_get_task.return_value = self.task
     self.task.succeed.side_effect = Exception('testing')
     complete = import_flow._CompleteTask(TASK_ID1, TASK_TYPE,
                                          self.task_repo, self.wrapper)
     complete.execute()
     self.task.fail.assert_called_once_with(
         _('Error: <class \'Exception\'>: testing'))
     self.task_repo.save.assert_called_once_with(self.task)
     self.wrapper.drop_lock_for_task.assert_called_once_with()
Ejemplo n.º 4
0
 def test_execute_drop_lock_fails(self, mock_get_task):
     mock_get_task.return_value = self.task
     self.wrapper.drop_lock_for_task.side_effect = exception.NotFound()
     complete = import_flow._CompleteTask(TASK_ID1, TASK_TYPE,
                                          self.task_repo, self.wrapper)
     with mock.patch('glance.async_.flows.api_image_import.LOG') as m_log:
         complete.execute()
         m_log.error.assert_called_once_with('Image %(image)s import task '
                                             '%(task)s did not hold the '
                                             'lock upon completion!',
                                             {'image': IMAGE_ID1,
                                              'task': TASK_ID1})
     self.task.succeed.assert_called_once_with({'image_id': IMAGE_ID1})