Example #1
0
 def test_queued(self, m_tags, m_set):
     """
     Test that the set_importer task is queued correctly.
     """
     repo = model.Repository('m_id')
     result = importer.queue_set_importer(repo, 'm_type', 'm_conf')
     m_task_tags = [m_tags.resource_tag.return_value, m_tags.action_tag.return_value]
     m_set.apply_async_with_reservation.assert_called_once_with(
         m_tags.RESOURCE_REPOSITORY_TYPE, 'm_id', ['m_id', 'm_type'],
         {'repo_plugin_config': 'm_conf'}, tags=m_task_tags)
     self.assertTrue(result is m_set.apply_async_with_reservation.return_value)
Example #2
0
 def test_queued(self, m_tags, m_set):
     """
     Test that the set_importer task is queued correctly.
     """
     repo = model.Repository('m_id')
     result = importer.queue_set_importer(repo, 'm_type', 'm_conf')
     m_task_tags = [m_tags.resource_tag.return_value, m_tags.action_tag.return_value]
     m_set.apply_async_with_reservation.assert_called_once_with(
         m_tags.RESOURCE_REPOSITORY_TYPE, 'm_id', ['m_id', 'm_type'],
         {'repo_plugin_config': 'm_conf'}, tags=m_task_tags)
     self.assertTrue(result is m_set.apply_async_with_reservation.return_value)
Example #3
0
    def post(self, request, repo_id):
        """
        Associate an importer with a repository.

        This will validate that the repository exists and that there is an importer with the
        importer_type_id given. However, the importer configuration validation only checks the
        provided values against a standard set of importer configuration keys. The importer
        specific validation is called on association, so any type specific configuration will
        be validated later. This means the spawned task could fail with a validation error.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param repo_id: the repository to associate the importer with
        :type  repo_id: str

        :raises exceptions.OperationPostponed: dispatch a task
        """
        importer_type = request.body_as_json.get('importer_type_id', None)
        config = request.body_as_json.get('importer_config', None)
        importer_controller.validate_importer_config(repo_id, importer_type, config)
        repo = model.Repository.objects.get_repo_or_missing_resource(repo_id)
        async_result = importer_controller.queue_set_importer(repo, importer_type, config)
        raise exceptions.OperationPostponed(async_result)
Example #4
0
    def post(self, request, repo_id):
        """
        Associate an importer with a repository.

        This will validate that the repository exists and that there is an importer with the
        importer_type_id given. However, the importer configuration validation only checks the
        provided values against a standard set of importer configuration keys. The importer
        specific validation is called on association, so any type specific configuration will
        be validated later. This means the spawned task could fail with a validation error.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param repo_id: the repository to associate the importer with
        :type  repo_id: str

        :raises exceptions.OperationPostponed: dispatch a task
        """
        importer_type = request.body_as_json.get('importer_type_id', None)
        config = request.body_as_json.get('importer_config', None)
        importer_controller.validate_importer_config(repo_id, importer_type, config)
        repo = model.Repository.objects.get_repo_or_missing_resource(repo_id)
        async_result = importer_controller.queue_set_importer(repo, importer_type, config)
        raise exceptions.OperationPostponed(async_result)