本文整理汇总了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)
示例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)
示例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/')
示例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
示例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])
示例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)
示例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)