def test_sync_with_publish(self, mock_managers, mock_publish): mock_managers.repo_sync_manager.return_value.sync.return_value = 'baz' mock_managers.repo_publish_manager.return_value.auto_distributors.return_value = \ [{'id': 'flux'}] mock_publish.return_value = 'fish' result = repository.sync_with_auto_publish('foo', 'bar') self.assertTrue(isinstance(result, TaskResult)) self.assertEquals(result.spawned_tasks, ['fish', ])
def test_sync_with_publish(self, mock_managers, mock_publish): mock_managers.repo_sync_manager.return_value.sync.return_value = 'baz' mock_managers.repo_publish_manager.return_value.auto_distributors.return_value = \ [{'id': 'flux'}] mock_publish.return_value = 'fish' result = repository.sync_with_auto_publish('foo', 'bar') self.assertTrue(isinstance(result, TaskResult)) self.assertEquals(result.spawned_tasks, [ 'fish', ])
def POST(self, repo_id): # Params params = self.params() overrides = params.get('override_config', None) # Check for repo existence and let the missing resource bubble up manager_factory.repo_query_manager().get_repository(repo_id) # Execute the sync asynchronously async_result = repository.sync_with_auto_publish(repo_id, overrides) # this raises an exception that is handled by the middleware, # so no return is needed raise exceptions.OperationPostponed(async_result)
def post(self, request, repo_id): """ Dispatch a task to sync a repository. :param request: WSGI request object :type request: django.core.handlers.wsgi.WSGIRequest :param repo_id: id of the repository to sync :type repo_id: str :raises pulp_exceptions.OperationPostponed: dispatch a sync repo task """ overrides = request.body_as_json.get('override_config', None) # Check for repo existence and let the missing resource bubble up manager_factory.repo_query_manager().get_repository(repo_id) async_result = repo_tasks.sync_with_auto_publish(repo_id, overrides) raise pulp_exceptions.OperationPostponed(async_result)
def test_sync_alone(self, mock_managers): mock_managers.repo_sync_manager.return_value.sync.return_value = 'baz' result = repository.sync_with_auto_publish('foo', 'bar') self.assertTrue(isinstance(result, TaskResult)) self.assertEquals(result.return_value, 'baz')
def test_pass_through_to_manager(self, mock_queue_sync): result = repository.sync_with_auto_publish('foo', {}) # make sure the args get passed through mock_queue_sync.assert_called_once_with('foo', {}) # make sure the return value is passed through self.assertTrue(result is mock_queue_sync.return_value)