示例#1
0
    def test_delete(self, mock_get_importer, mock_delete):
        mock_get_importer.return_value = {'id': self.importer}

        RepoSyncScheduleManager.delete(self.repo, self.importer,
                                       self.schedule_id)

        mock_delete.assert_called_once_with(self.schedule_id)
示例#2
0
    def test_validate_options(self, mock_get_importer, mock_validate_options,
                              mock_update):
        mock_get_importer.return_value = {'id': self.importer}

        RepoSyncScheduleManager.update(self.repo, self.importer,
                                       self.schedule_id, self.updates)

        mock_validate_options.assert_called_once_with(self.updates)
示例#3
0
    def test_update_overrides(self, mock_get_importer, mock_update):
        mock_get_importer.return_value = {'id': self.importer}

        RepoSyncScheduleManager.update(self.repo, self.importer, self.schedule_id,
                                       {'override_config': {'foo': 'bar'}})

        mock_update.assert_called_once_with(self.schedule_id,
                                            {'kwargs': {'overrides': {'foo': 'bar'}}})
示例#4
0
    def test_utils_validation(self, mock_validate_keys, mock_validate_options,
                              mock_validate_importer, mock_save):
        RepoSyncScheduleManager.create(self.repo, self.importer, self.options,
                                       self.schedule)

        mock_validate_keys.assert_called_once_with(self.options,
                                                   ('override_config', ))
        mock_validate_options.assert_called_once_with(self.schedule, None,
                                                      True)
示例#5
0
    def remove_importer(repo_id):
        """
        Removes an importer from a repository.

        :param repo_id:         identifies the repo
        :type  repo_id:         str
        :raise MissingResource: if the given repo does not exist
        :raise MissingResource: if the given repo does not have an importer
        """

        importer_coll = RepoImporter.get_collection()

        # Validation
        repo_obj = model.Repository.objects.get_repo_or_missing_resource(repo_id)

        repo_importer = importer_coll.find_one({'repo_id': repo_id})

        if repo_importer is None:
            raise MissingResource(repo_id)

        # remove schedules
        RepoSyncScheduleManager().delete_by_importer_id(repo_id, repo_importer['id'])

        # Call the importer's cleanup method
        importer_type_id = repo_importer['importer_type_id']
        importer_instance, plugin_config = plugin_api.get_importer_by_id(importer_type_id)

        call_config = PluginCallConfiguration(plugin_config, repo_importer['config'])

        transfer_repo = repo_obj.to_transfer_repo()

        importer_instance.importer_removed(transfer_repo, call_config)

        # Update the database to reflect the removal
        importer_coll.remove({'repo_id': repo_id})
示例#6
0
文件: test_repo.py 项目: pcreech/pulp
    def test_update(self, mock_update, mock_valid_imp):
        ret = RepoSyncScheduleManager.update(self.repo, self.importer, self.schedule_id, self.updates)

        mock_update.assert_called_once_with(self.schedule_id, self.updates)
        mock_valid_imp.assert_called_once_with(self.repo, self.importer)
        # make sure it passes through the return value from utils.update
        self.assertEqual(ret, mock_update.return_value)
示例#7
0
文件: test_repo.py 项目: pcreech/pulp
    def test_save(self, mock_save, *_):
        ret = RepoSyncScheduleManager.create(self.repo, self.importer, self.options, self.schedule, 3, False)

        mock_save.assert_called_once_with()
        self.assertTrue(isinstance(ret, ScheduledCall))
        self.assertEqual(ret.iso_schedule, self.schedule)
        self.assertEqual(ret.failure_threshold, 3)
        self.assertTrue(ret.enabled is False)
示例#8
0
    def test_update(self, mock_get_importer, mock_update):
        mock_get_importer.return_value = {'id': self.importer}

        ret = RepoSyncScheduleManager.update(self.repo, self.importer,
                                             self.schedule_id, self.updates)

        mock_update.assert_called_once_with(self.schedule_id, self.updates)
        # make sure it passes through the return value from utils.update
        self.assertEqual(ret, mock_update.return_value)
示例#9
0
    def test_save(self, mock_get_importer, mock_save):
        mock_get_importer.return_value = {'id': 'importer1'}

        ret = RepoSyncScheduleManager.create(self.repo, self.importer, self.options,
                                             self.schedule, 3, False)

        mock_save.assert_called_once_with()
        self.assertTrue(isinstance(ret, ScheduledCall))
        self.assertEqual(ret.iso_schedule, self.schedule)
        self.assertEqual(ret.failure_threshold, 3)
        self.assertTrue(ret.enabled is False)
示例#10
0
文件: test_repo.py 项目: pcreech/pulp
 def test_calls_delete_resource(self, mock_delete_by, mock_imp_ctrl):
     RepoSyncScheduleManager.delete_by_importer_id(self.repo, self.importer)
     mock_delete_by.assert_called_once_with(mock_imp_ctrl.build_resource_tag.return_value)
示例#11
0
    def test_utils_validation(self, mock_validate_keys, mock_validate_options, mock_validate_importer, mock_save):
        RepoSyncScheduleManager.create(self.repo, self.importer, self.options, self.schedule)

        mock_validate_keys.assert_called_once_with(self.options, ("override_config",))
        mock_validate_options.assert_called_once_with(self.schedule, None, True)
示例#12
0
    def test_list(self, mock_get_by_resource, mock_validate_importer):
        ret = RepoSyncScheduleManager.list("repo1", "importer1")

        mock_get_by_resource.assert_called_once_with(RepoImporter.build_resource_tag("repo1", "importer1"))
        self.assertTrue(ret is mock_get_by_resource.return_value)
示例#13
0
    def test_list(self, mock_get_by_resource, mock_validate_importer):
        ret = RepoSyncScheduleManager.list('repo1', 'importer1')

        mock_get_by_resource.assert_called_once_with(
            RepoImporter.build_resource_tag('repo1', 'importer1'))
        self.assertTrue(ret is mock_get_by_resource.return_value)
示例#14
0
    def test_calls_delete_resource(self, mock_delete_by):
        resource = RepoImporter.build_resource_tag(self.repo, self.importer)

        RepoSyncScheduleManager.delete_by_importer_id(self.repo, self.importer)

        mock_delete_by.assert_called_once_with(resource)
示例#15
0
    def test_delete(self, mock_get_importer, mock_delete):
        mock_get_importer.return_value = {"id": self.importer}

        RepoSyncScheduleManager.delete(self.repo, self.importer, self.schedule_id)

        mock_delete.assert_called_once_with(self.schedule_id)
示例#16
0
    def test_update_overrides(self, mock_get_importer, mock_update):
        mock_get_importer.return_value = {"id": self.importer}

        RepoSyncScheduleManager.update(self.repo, self.importer, self.schedule_id, {"override_config": {"foo": "bar"}})

        mock_update.assert_called_once_with(self.schedule_id, {"kwargs": {"overrides": {"foo": "bar"}}})
示例#17
0
    def test_validate_options(self, mock_get_importer, mock_validate_options, mock_update):
        mock_get_importer.return_value = {"id": self.importer}

        RepoSyncScheduleManager.update(self.repo, self.importer, self.schedule_id, self.updates)

        mock_validate_options.assert_called_once_with(self.updates)
示例#18
0
    def test_matching_importer(self, mock_get_importer):
        mock_get_importer.return_value = {'id': 'importer1'}

        RepoSyncScheduleManager.validate_importer('repo1', 'importer1')

        mock_get_importer.assert_called_once_with('repo1')
示例#19
0
文件: test_repo.py 项目: pcreech/pulp
 def test_delete(self, mock_delete, mock_valid_imp):
     RepoSyncScheduleManager.delete(self.repo, self.importer, self.schedule_id)
     mock_valid_imp.assert_called_once_with(self.repo, self.importer)
     mock_delete.assert_called_once_with(self.schedule_id)
示例#20
0
文件: test_repo.py 项目: pcreech/pulp
    def test_update_overrides(self, mock_update, mock_valid_imp):
        RepoSyncScheduleManager.update(self.repo, self.importer, self.schedule_id, {"override_config": {"foo": "bar"}})

        mock_update.assert_called_once_with(self.schedule_id, {"kwargs": {"overrides": {"foo": "bar"}}})
示例#21
0
    def test_validate_importer(self, mock_get_by_resource,
                               mock_validate_importer):
        RepoSyncScheduleManager.list('repo1', 'importer1')

        mock_validate_importer.assert_called_once_with('repo1', 'importer1')
示例#22
0
    def test_matching_importer(self, mock_get_importer):
        mock_get_importer.return_value = {"id": "importer1"}

        RepoSyncScheduleManager.validate_importer("repo1", "importer1")

        mock_get_importer.assert_called_once_with("repo1")
示例#23
0
    def test_matching_importer(self, mock_get_importer):
        mock_get_importer.return_value = {'id': 'importer1'}

        RepoSyncScheduleManager.validate_importer('repo1', 'importer1')

        mock_get_importer.assert_called_once_with('repo1')
示例#24
0
    def test_validate_importer(self, mock_get_by_resource, mock_validate_importer):
        RepoSyncScheduleManager.list("repo1", "importer1")

        mock_validate_importer.assert_called_once_with("repo1", "importer1")
示例#25
0
    def test_calls_delete_resource(self, mock_delete_by):
        resource = RepoImporter.build_resource_tag(self.repo, self.importer)

        RepoSyncScheduleManager.delete_by_importer_id(self.repo, self.importer)

        mock_delete_by.assert_called_once_with(resource)
示例#26
0
文件: test_repo.py 项目: pcreech/pulp
 def test_validate_options(self, mock_validate_options, mock_update, mock_valid_imp):
     RepoSyncScheduleManager.update(self.repo, self.importer, self.schedule_id, self.updates)
     mock_validate_options.assert_called_once_with(self.updates)