本文整理汇总了Python中pulp.server.content.sources.container.ContentContainer.threaded方法的典型用法代码示例。如果您正苦于以下问题:Python ContentContainer.threaded方法的具体用法?Python ContentContainer.threaded怎么用?Python ContentContainer.threaded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.content.sources.container.ContentContainer
的用法示例。
在下文中一共展示了ContentContainer.threaded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_download_to_stream
# 需要导入模块: from pulp.server.content.sources.container import ContentContainer [as 别名]
# 或者: from pulp.server.content.sources.container.ContentContainer import threaded [as 别名]
def test_download_to_stream(self):
request_list = []
_dir, cataloged = self.populate_catalog(ORPHANED, 0, 10)
_dir, cataloged = self.populate_catalog(UNIT_WORLD, 0, 10)
_dir = self.populate_content(PRIMARY, 0, 20)
# unit-world
for n in range(0, 10):
request = Request(
cataloged[n].type_id,
cataloged[n].unit_key,
'file://%s/unit_%d' % (_dir, n),
StringIO())
request_list.append(request)
# primary
for n in range(11, 20):
unit_key = {
'name': 'unit_%d' % n,
'version': '1.0.%d' % n,
'release': '1',
'checksum': str(uuid4())
}
request = Request(
TYPE_ID,
unit_key,
'file://%s/unit_%d' % (_dir, n),
StringIO())
request_list.append(request)
downloader = LocalFileDownloader(DownloaderConfig())
listener = Mock()
container = ContentContainer(path=self.tmp_dir)
container.threaded = False
container.refresh = Mock()
# test
report = container.download(downloader, request_list, listener)
# validation
# unit-world
for i in range(0, 10):
request = request_list[i]
self.assertTrue(request.downloaded)
self.assertEqual(len(request.errors), 0)
fp = request.destination
s = fp.getvalue()
self.assertTrue(UNIT_WORLD in s)
# primary
for i in range(11, len(request_list)):
request = request_list[i]
self.assertTrue(request.downloaded)
self.assertEqual(len(request.errors), 0)
fp = request.destination
s = fp.getvalue()
self.assertTrue(PRIMARY in s)
self.assertEqual(report.total_sources, 2)
self.assertEqual(len(report.downloads), 2)
self.assertEqual(report.downloads[PRIMARY_ID].total_succeeded, 9)
self.assertEqual(report.downloads[PRIMARY_ID].total_failed, 0)
self.assertEqual(report.downloads[UNIT_WORLD].total_succeeded, 10)
self.assertEqual(report.downloads[UNIT_WORLD].total_failed, 0)
示例2: test_serial_download
# 需要导入模块: from pulp.server.content.sources.container import ContentContainer [as 别名]
# 或者: from pulp.server.content.sources.container.ContentContainer import threaded [as 别名]
def test_serial_download(self, fake_load, fake_refresh, fake_primary, fake_batch):
path = Mock()
downloader = Mock()
requests = Mock()
listener = Mock()
_batch = Mock()
_batch.download.return_value = 123
fake_batch.return_value = _batch
# test
container = ContentContainer(path)
container.threaded = False
report = container.download(downloader, requests, listener)
# validation
fake_load.assert_called_with(path)
fake_refresh.assert_called_with()
fake_primary.assert_called_with(downloader)
fake_batch.assert_called_with(fake_primary(), container, requests, listener)
_batch.assert_called_with()
self.assertEqual(report, _batch.return_value)