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


Python ContentSource.load_all方法代码示例

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


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

示例1: test_load_all

# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import load_all [as 别名]
    def test_load_all(self, fake_valid, fake_enabled, fake_parser, fake_listdir, fake_isfile):
        conf_d = '/fake/conf_d'
        files = ['one.conf', 'other']
        fake_listdir.return_value = files

        fake_valid.side_effect = [
            True,  # s-0
                   # s-1 not enabled
            True,  # s-2
            False  # s-3
        ]

        fake_isfile.side_effect = [True, False]

        fake_enabled.__get__ = Mock(side_effect=[d[1]['enabled'] for d in DESCRIPTOR])

        parser = Mock()
        parser.items.side_effect = [d[1].items() for d in DESCRIPTOR]
        parser.sections.return_value = [d[0] for d in DESCRIPTOR]
        fake_parser.return_value = parser

        # test

        sources = ContentSource.load_all(conf_d)

        # validation

        fake_listdir.assert_called_with(conf_d)
        fake_parser.assert_called_with()
        fake_parser().read.assert_called_with(os.path.join(conf_d, files[0]))

        self.assertEqual(len(sources), 2)
        self.assertTrue(DESCRIPTOR[0][0] in sources)
        self.assertTrue(DESCRIPTOR[2][0] in sources)
开发者ID:kevinaloys,项目名称:pulp,代码行数:36,代码来源:test_model.py

示例2: __init__

# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import load_all [as 别名]
 def __init__(self, path=None):
     """
     :param path: The absolute path to a directory containing
         content source descriptor files.
     :type path: str
     """
     self.sources = ContentSource.load_all(path)
开发者ID:aweiteka,项目名称:pulp,代码行数:9,代码来源:container.py

示例3: test_urls

# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import load_all [as 别名]
 def test_urls(self):
     sources = ContentSource.load_all(self.tmp_dir)
     underground = sources[UNDERGROUND]
     urls = underground.urls
     self.assertEqual(len(urls), 4)
     self.assertEqual(urls[0], 'file:///underground/fedora/18/x86_64/')
     self.assertEqual(urls[1], 'file:///underground/fedora/18/i386/')
     self.assertEqual(urls[2], 'file:///underground/fedora/19/x86_64/')
     self.assertEqual(urls[3], 'file:///underground/fedora/19/i386/')
开发者ID:alanoe,项目名称:pulp,代码行数:11,代码来源:test_content_sources.py

示例4: __init__

# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import load_all [as 别名]
 def __init__(self, path=None, threaded=True):
     """
     :param path:     The absolute path to a directory containing
                      content source descriptor files.
     :type  path:     str
     :param threaded: Whether or not to use the threaded download method.
     :type  threaded: bool
     """
     self.sources = ContentSource.load_all(path)
     self.threaded = threaded
开发者ID:maxamillion,项目名称:pulp,代码行数:12,代码来源:container.py

示例5: test_load_all_unreadable

# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import load_all [as 别名]
    def test_load_all_unreadable(self, mock_warn, mock_read, mock_listdir, mock_isfile):
        conf_d = '/mock/conf_d/'
        mock_listdir.return_value = ['somefile.conf']
        # this return value indicates that the read did not succeed
        mock_read.return_value = []

        sources = ContentSource.load_all(conf_d)

        # make sure no sources are returned, and a message was logged with the path
        self.assertEqual(len(sources), 0)
        self.assertEqual(mock_warn.call_count, 1)
        self.assertEqual(os.path.join(conf_d, 'somefile.conf'), mock_warn.call_args[0][1])
开发者ID:alanoe,项目名称:pulp,代码行数:14,代码来源:test_model.py

示例6: test_refresh

# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import load_all [as 别名]
    def test_refresh(self, mock_plugin):
        container = ContentContainer(path=self.tmp_dir)

        # test
        report = container.refresh(force=True)

        # validation
        plugin = mock_plugin.return_value[0]
        self.assertEqual(plugin.refresh.call_count, 5)
        self.assertEqual(len(report), 5)
        for r in report:
            self.assertTrue(r.succeeded)
            self.assertEqual(r.added_count, 100)
            self.assertEqual(r.deleted_count, 0)
        calls = iter(plugin.refresh.call_args_list)
        for source in ContentSource.load_all(self.tmp_dir).values():
            for url in source.urls:
                args = calls.next()[0]
                self.assertTrue(isinstance(args[0], CatalogerConduit))
                self.assertEqual(args[1], source.descriptor)
                self.assertEqual(args[2], url)
开发者ID:alanoe,项目名称:pulp,代码行数:23,代码来源:test_content_sources.py

示例7: test_loading

# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import load_all [as 别名]
 def test_loading(self):
     sources = ContentSource.load_all(self.tmp_dir)
     self.assertEqual(len(sources), 2)
开发者ID:alanoe,项目名称:pulp,代码行数:5,代码来源:test_content_sources.py


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