예제 #1
0
 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', ])
예제 #2
0
 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',
     ])
예제 #3
0
파일: repositories.py 프로젝트: beav/pulp
    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)
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
0
 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')
예제 #7
0
 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)
예제 #8
0
 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)
예제 #9
0
 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')