def test_as_expected(self, mock_get_imp, mock_tags, mock_rm_importer): """ Dispatch a task as expected. """ result = importer.queue_remove_importer('mock_r', 'mock_type') mock_get_imp.assert_called_once_with('mock_r', 'mock_type') call_tags = [mock_tags.resource_tag.return_value, mock_tags.resource_tag.return_value, mock_tags.action_tag.return_value] mock_rm_importer.apply_async_with_reservation.assert_called_once_with( mock_tags.RESOURCE_REPOSITORY_TYPE, 'mock_r', ['mock_r'], tags=call_tags) self.assertTrue(result is mock_rm_importer.apply_async_with_reservation.return_value)
def delete(self, request, repo_id, importer_id): """ Dispatch a task to remove an importer from a repository. :param request: WSGI request object :type request: django.core.handlers.wsgi.WSGIRequest :param repo_id: The id of the repository to remove the importer from :type repo_id: str :param importer_id: The id of the importer to remove from the given repository :type importer_id: str :raises exceptions.OperationPostponed: to dispatch a task to delete the importer """ importer_controller.get_valid_importer(repo_id, importer_id) async_result = importer_controller.queue_remove_importer(repo_id, importer_id) raise exceptions.OperationPostponed(async_result)