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


Python SynchronizeWithDirectory.tmp_dir方法代码示例

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


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

示例1: test_fetch_modules_failures

# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import tmp_dir [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

示例2: test_fetch_modules

# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import tmp_dir [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.tmp_dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。