当前位置: 首页>>代码示例>>Python>>正文


Python SynchronizeWithDirectory.report方法代码示例

本文整理汇总了Python中pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory.report方法的典型用法代码示例。如果您正苦于以下问题:Python SynchronizeWithDirectory.report方法的具体用法?Python SynchronizeWithDirectory.report怎么用?Python SynchronizeWithDirectory.report使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory的用法示例。


在下文中一共展示了SynchronizeWithDirectory.report方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_fetch_manifest_failed

# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import report [as 别名]
    def test_fetch_manifest_failed(self, mock_download):
        feed_url = 'http://host/root/'

        mock_repo = Mock()
        conduit = Mock()
        config = {constants.CONFIG_FEED: feed_url}
        failed_report = Mock()
        failed_report.error_msg = 'just up and failed'

        mock_download.return_value = [], [failed_report]

        # test

        method = SynchronizeWithDirectory(mock_repo, conduit, config)
        method.report = Mock()
        manifest = method._fetch_manifest()

        # validation

        mock_download.assert_called_with([(urljoin(feed_url, constants.MANIFEST_FILENAME), ANY)])

        self.assertTrue(manifest is None)

        self.assertTrue(method.report.update_progress.called)
        self.assertEqual(method.report.metadata_state, constants.STATE_FAILED)
        self.assertEqual(method.report.metadata_error_message, failed_report.error_msg)
        self.assertTrue(method.report.metadata_execution_time > 0)
开发者ID:aeria,项目名称:pulp_puppet,代码行数:29,代码来源:test_directory.py

示例2: test_fetch_manifest

# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import report [as 别名]
    def test_fetch_manifest(self, mock_download, mock_get_value):
        feed_url = 'http://host/root/'

        mock_repo = Mock()
        conduit = Mock()
        config = {constants.CONFIG_FEED: feed_url}
        succeeded_report = Mock()

        mock_download.return_value = [succeeded_report], []
        mock_get_value.return_value = 'A,B,C\nD,E,F\n'

        # test

        method = SynchronizeWithDirectory(mock_repo, conduit, config)
        method.report = Mock()
        manifest = method._fetch_manifest()

        # validation

        mock_download.assert_called_with([(urljoin(feed_url, constants.MANIFEST_FILENAME), ANY)])

        self.assertEqual(manifest, [('A', 'B', 'C'), ('D', 'E', 'F')])

        self.assertTrue(method.report.update_progress.called)
        self.assertEqual(method.report.metadata_state, constants.STATE_SUCCESS)
        self.assertEqual(method.report.metadata_query_finished_count, 1)
        self.assertEqual(method.report.metadata_query_total_count, 1)
        self.assertEqual(method.report.metadata_current_query, None)
        self.assertTrue(method.report.metadata_execution_time > 0)
开发者ID:aeria,项目名称:pulp_puppet,代码行数:31,代码来源:test_directory.py

示例3: test_import_modules_failed

# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import report [as 别名]
    def test_import_modules_failed(self):
        """
        Test that when there was some failure in a previous step, _import_modules does not
        overwrite the failed state
        """
        config = {}
        mock_conduit = Mock()

        mock_inventory = Mock()
        method = SynchronizeWithDirectory(mock_conduit, config)
        method.started_fetch_modules = 0
        method._extract_metadata = Mock(return_value={'name': 'j-p', 'author': 'J', 'version': '1.1'})
        method.report = Mock()
        method.report.modules_total_count = 1
        method.report.modules_finished_count = 0
        method.report.modules_state = constants.STATE_FAILED

        # test
        imported_modules = method._import_modules(mock_inventory, ['/path1'])

        # validation
        self.assertEquals(constants.STATE_FAILED, method.report.modules_state)
        self.assertEquals(1, method.report.update_progress.call_count)
        self.assertEquals(0, method.report.modules_total_count)
        self.assertEquals(0, method.report.modules_finished_count)
        self.assertEquals([], imported_modules)
开发者ID:asmacdo,项目名称:pulp_puppet,代码行数:28,代码来源:test_directory.py

示例4: test_import_modules

# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import report [as 别名]
    def test_import_modules(self, mock_extract, mock_add, mock_remove_missing):
        # These manifests represent the parsed metadata.json file. These contain a 'name'
        # field, where we retrieve both the unit key's 'name' and 'author' field.
        manifest = [{'name': 'john-pulp1', 'author': 'Johnathon', 'version': '1.0'}]
        mock_extract.side_effect = manifest
        module_paths = ['/tmp/module_1']
        mock_pulp1, mock_pulp2 = (Mock(), Mock())
        mock_pulp1.unit_key = {'name': 'pulp1', 'author': 'john', 'version': '1.0'}
        mock_pulp2.unit_key = {'name': 'pulp2', 'author': 'john', 'version': '2.0'}
        conduit = Mock()
        conduit.get_units.return_value = [mock_pulp1, mock_pulp2]
        config = Mock()
        config.get_boolean.return_value = True

        # test
        method = SynchronizeWithDirectory(conduit, config)
        method.started_fetch_modules = 10
        method.report = Mock()
        method.report.modules_total_count = 2
        method.report.modules_finished_count = 0
        method._import_modules(module_paths)

        # validation
        config.get_boolean.assert_called_once_with(constants.CONFIG_REMOVE_MISSING)
        mock_remove_missing.assert_called_once_with([mock_pulp1, mock_pulp2], [mock_pulp1.unit_key])
开发者ID:bmbouter,项目名称:pulp_puppet,代码行数:27,代码来源:test_directory.py

示例5: test_import_modules

# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import report [as 别名]
    def test_import_modules(self, mock_extract, mock_add):
        feed_url = 'http://host/root/PULP_MANAFEST'

        conduit = Mock()
        config = {constants.CONFIG_FEED: feed_url}

        mock_inventory = Mock()
        mock_inventory.already_associated.side_effect = [False, True, False]

        # These manifests represent the parsed metadata.json file. These contain a 'name'
        # field, where we retrieve both the unit key's 'name' and 'author' field.
        manifests = [
            {'name': 'john-pulp1', 'author': 'Johnathon', 'version': '1.0'},
            {'name': 'john-pulp2', 'author': 'Johnathon', 'version': '2.0'},
            {'name': 'john/pulp3', 'author': 'Johnathon', 'version': '3.0'},
        ]
        mock_extract.side_effect = manifests

        unit_keys = [
            {'name': 'pulp1', 'author': 'john', 'version': '1.0'},
            {'name': 'pulp2', 'author': 'john', 'version': '2.0'},
            {'name': 'pulp3', 'author': 'john', 'version': '3.0'},
        ]

        module_paths = [
            '/tmp/module_1',
            '/tmp/module_2',
            '/tmp/module_3',
        ]

        # test
        method = SynchronizeWithDirectory(conduit, config)
        method.started_fetch_modules = 10
        method.report = Mock()
        method.report.modules_total_count = 3
        method.report.modules_finished_count = 0
        imported_modules = method._import_modules(mock_inventory, module_paths)

        # validation
        mock_add.assert_any_with(module_paths[0], ANY)
        mock_add.assert_any_with(module_paths[2], ANY)

        # should only be modules 1 and 3.  2 already associated.
        self.assertEqual(len(imported_modules), 2)
        self.assertEqual(imported_modules[0], unit_keys[0])
        self.assertEqual(imported_modules[1], unit_keys[2])

        # Check that the progress reporting was called as expected
        self.assertEquals(3, method.report.update_progress.call_count)
        self.assertEquals(2, method.report.modules_finished_count)
        self.assertEquals(2, method.report.modules_total_count)
开发者ID:asmacdo,项目名称:pulp_puppet,代码行数:53,代码来源:test_directory.py

示例6: test_fetch_modules_failures

# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import report [as 别名]
    def test_fetch_modules_failures(self, mock_download):
        tmp_dir = '/tmp/puppet-testing'
        feed_url = 'http://host/root/'

        mock_repo = Mock()
        conduit = Mock()
        config = {constants.CONFIG_FEED: feed_url}

        manifest = [('path1', 'AA', 10), ('path2', 'BB', 20)]

        report_1 = Mock()
        report_1.destination = os.path.join(tmp_dir, manifest[0][0])
        report_2 = Mock()
        report_2.destination = os.path.join(tmp_dir, manifest[1][0])
        report_2.error_msg = 'it just dont work'
        mock_download.return_value = [report_1], [report_2]

        # test

        method = SynchronizeWithDirectory(mock_repo, conduit, config)
        method.report = Mock()
        method.tmp_dir = '/tmp/puppet-testing'
        module_paths = method._fetch_modules(manifest)

        # validation

        url_1 = os.path.join(feed_url, manifest[0][0])
        url_2 = os.path.join(feed_url, manifest[1][0])

        mock_download.assert_any_with([(url_1, report_1.destination)])
        mock_download.assert_any_with([(url_2, report_2.destination)])

        self.assertEqual(len(module_paths), 1)
        self.assertEqual(module_paths[0], report_1.destination)

        self.assertTrue(method.report.update_progress.called)
        self.assertEqual(method.report.modules_state, constants.STATE_FAILED)
        self.assertEqual(method.report.modules_error_count, 1)
        self.assertEqual(len(method.report.modules_individual_errors), 1)
        self.assertEqual(method.report.modules_individual_errors[0], report_2.error_msg)
开发者ID:aeria,项目名称:pulp_puppet,代码行数:42,代码来源:test_directory.py

示例7: test_fetch_modules

# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import report [as 别名]
    def test_fetch_modules(self, mock_download):
        tmp_dir = '/tmp/puppet-testing'
        feed_url = 'http://host/root/'

        mock_repo = Mock()
        conduit = Mock()
        config = {constants.CONFIG_FEED: feed_url}

        manifest = [('path1', 'AA', 10), ('path2', 'BB', 20)]

        report_1 = Mock()
        report_1.destination = os.path.join(tmp_dir, manifest[0][0])
        report_2 = Mock()
        report_2.destination = os.path.join(tmp_dir, manifest[1][0])
        mock_download.return_value = [report_1, report_2], []

        # test

        method = SynchronizeWithDirectory(mock_repo, conduit, config)
        method.report = Mock()
        method.tmp_dir = '/tmp/puppet-testing'
        module_paths = method._fetch_modules(manifest)

        # validation

        url_1 = os.path.join(feed_url, manifest[0][0])
        url_2 = os.path.join(feed_url, manifest[1][0])

        mock_download.assert_any_with([(url_1, report_1.destination)])
        mock_download.assert_any_with([(url_2, report_2.destination)])

        self.assertEqual(len(module_paths), 2)
        self.assertEqual(module_paths[0], report_1.destination)
        self.assertEqual(module_paths[1], report_2.destination)

        # Assert the progress report was updated and the report is still in the running state.
        # The _import_modules method must be called to complete the task.
        self.assertTrue(method.report.update_progress.called)
        self.assertEqual(method.report.modules_state, constants.STATE_RUNNING)
开发者ID:aeria,项目名称:pulp_puppet,代码行数:41,代码来源:test_directory.py


注:本文中的pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory.report方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。