def test_revert_copy_status_unchanged(self): wrapper = mock.MagicMock() task = import_flow._VerifyImageState(TASK_ID1, TASK_TYPE, wrapper, 'copy-image') task.revert(mock.sentinel.result) # If we are doing copy-image, no state update should be made wrapper.__enter__.return_value.set_image_status.assert_not_called()
def test_reverts_state_nocopy(self): wrapper = mock.MagicMock() task = import_flow._VerifyImageState(TASK_ID1, TASK_TYPE, wrapper, 'glance-direct') task.revert(mock.sentinel.result) # Except for copy-image, image state should revert to queued action = wrapper.__enter__.return_value action.set_image_status.assert_called_once_with('queued')
def test_verify_active_status(self): fake_img = mock.MagicMock( status='active', extra_properties={'os_glance_import_task': TASK_ID1}) mock_repo = mock.MagicMock() mock_repo.get.return_value = fake_img wrapper = import_flow.ImportActionWrapper(mock_repo, IMAGE_ID1, TASK_ID1) task = import_flow._VerifyImageState(TASK_ID1, TASK_TYPE, wrapper, 'anything!') task.execute() fake_img.status = 'importing' self.assertRaises(import_flow._NoStoresSucceeded, task.execute)