Exemplo n.º 1
0
 def test_publish(self, mock_publish_task):
     repo_id = 'foo'
     distributor_id = 'bar'
     overrides = 'baz'
     repository.publish(repo_id, distributor_id, overrides)
     kwargs = {
         'repo_id': repo_id,
         'distributor_id': distributor_id,
         'publish_config_override': overrides
     }
     tags = [resource_tag(RESOURCE_REPOSITORY_TYPE, repo_id), action_tag('publish')]
     mock_publish_task.assert_called_with(RESOURCE_REPOSITORY_TYPE, repo_id, tags=tags,
                                          kwargs=kwargs)
Exemplo n.º 2
0
 def test_publish(self, mock_publish_task):
     repo_id = 'foo'
     distributor_id = 'bar'
     overrides = 'baz'
     repository.publish(repo_id, distributor_id, overrides)
     kwargs = {
         'repo_id': repo_id,
         'distributor_id': distributor_id,
         'publish_config_override': overrides
     }
     tags = [
         resource_tag(RESOURCE_REPOSITORY_TYPE, repo_id),
         action_tag('publish')
     ]
     mock_publish_task.assert_called_with(RESOURCE_REPOSITORY_TYPE,
                                          repo_id,
                                          tags=tags,
                                          kwargs=kwargs)
Exemplo n.º 3
0
    def POST(self, repo_id):
        # validation
        manager = manager_factory.repo_query_manager()
        manager.get_repository(repo_id)

        # Params
        params = self.params()
        distributor_id = params.get('id', None)
        overrides = params.get('override_config', None)
        async_result = repository.publish(repo_id, distributor_id, overrides)
        raise exceptions.OperationPostponed(async_result)
Exemplo n.º 4
0
    def POST(self, repo_id):
        # validation
        manager = manager_factory.repo_query_manager()
        manager.get_repository(repo_id)

        # Params
        params = self.params()
        distributor_id = params.get('id', None)
        overrides = params.get('override_config', None)
        async_result = repository.publish(repo_id, distributor_id, overrides)
        raise exceptions.OperationPostponed(async_result)
Exemplo n.º 5
0
    def post(self, request, repo_id):
        """
        Dispatch a task to publish a repository.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param repo_id: id of the repository to publish
        :type  repo_id: str

        :raises pulp_exceptions.MissingValue: if required param id is not passed
        :raises pulp_exceptions.OperationPostponed: dispatch a publish repo task
        """

        # validation
        manager = manager_factory.repo_query_manager()
        manager.get_repository(repo_id)

        distributor_id = request.body_as_json.get('id', None)
        if distributor_id is None:
            raise pulp_exceptions.MissingValue('id')
        overrides = request.body_as_json.get('override_config', None)
        async_result = repo_tasks.publish(repo_id, distributor_id, overrides)
        raise pulp_exceptions.OperationPostponed(async_result)
Exemplo n.º 6
0
 def test_pass_through_to_manager(self, mock_queue_publish):
     result = repository.publish('foo', 'dist1', {})
     # make sure the args get passed through
     mock_queue_publish.assert_called_once_with('foo', 'dist1', {})
     # make sure the return value is passed through
     self.assertTrue(result is mock_queue_publish.return_value)
Exemplo n.º 7
0
 def test_pass_through_to_manager(self, mock_queue_publish):
     result = repository.publish('foo', 'dist1', {})
     # make sure the args get passed through
     mock_queue_publish.assert_called_once_with('foo', 'dist1', {})
     # make sure the return value is passed through
     self.assertTrue(result is mock_queue_publish.return_value)