本文整理汇总了Python中pulp.server.content.sources.model.ContentSource.get_conduit方法的典型用法代码示例。如果您正苦于以下问题:Python ContentSource.get_conduit方法的具体用法?Python ContentSource.get_conduit怎么用?Python ContentSource.get_conduit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.content.sources.model.ContentSource
的用法示例。
在下文中一共展示了ContentSource.get_conduit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_refresh_raised
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_conduit [as 别名]
def test_refresh_raised(self, fake_urls):
url = 'http://xyz.com'
urls = ['url-1', 'url-2']
fake_urls.__get__ = Mock(return_value=urls)
canceled = Mock()
canceled.isSet = Mock(return_value=False)
conduit = Mock()
cataloger = Mock()
cataloger.refresh.side_effect = ValueError('just failed')
source = ContentSource('s-1', {constants.BASE_URL: url})
source.get_conduit = Mock(return_value=conduit)
source.get_cataloger = Mock(return_value=cataloger)
# test
report = source.refresh(canceled)
# validation
self.assertEqual(canceled.isSet.call_count, len(urls))
self.assertEqual(conduit.reset.call_count, len(urls))
self.assertEqual(cataloger.refresh.call_count, len(urls))
n = 0
for _url in source.urls:
cataloger.refresh.assert_any(conduit, source.descriptor, _url)
self.assertEqual(report[n].source_id, source.id)
self.assertEqual(report[n].url, _url)
self.assertFalse(report[n].succeeded)
self.assertEqual(report[n].errors, ['just failed'])
self.assertEqual(report[n].added_count, 0)
self.assertEqual(report[n].deleted_count, 0)
n += 1
示例2: test_refresh_canceled
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_conduit [as 别名]
def test_refresh_canceled(self, fake_urls):
url = 'http://xyz.com'
urls = ['url-1', 'url-2']
fake_urls.__get__ = Mock(return_value=urls)
canceled = Mock()
canceled.isSet = Mock(return_value=True)
conduit = Mock()
cataloger = Mock()
source = ContentSource('s-1', {constants.BASE_URL: url})
source.get_conduit = Mock(return_value=conduit)
source.get_cataloger = Mock(return_value=cataloger)
# test
report = source.refresh(canceled)
# validation
self.assertEqual(canceled.isSet.call_count, 1)
self.assertEqual(conduit.reset.call_count, 0)
self.assertEqual(cataloger.refresh.call_count, 0)
self.assertEqual(report, [])
示例3: test_conduit
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_conduit [as 别名]
def test_conduit(self):
source = ContentSource('s-1', {constants.EXPIRES: '1h'})
conduit = source.get_conduit()
self.assertEqual(conduit.source_id, source.id)
self.assertEqual(conduit.expires, 3600)
self.assertTrue(isinstance(conduit, CatalogerConduit))
示例4: test_downloader
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_conduit [as 别名]
def test_downloader(self):
url = 'http://xyz.com'
fake_conduit = Mock()
fake_cataloger = Mock()
fake_downloader = Mock()
fake_cataloger.get_downloader = Mock(return_value=fake_downloader)
source = ContentSource('s-1', {constants.BASE_URL: url})
source.get_conduit = Mock(return_value=fake_conduit)
source.get_cataloger = Mock(return_value=fake_cataloger)
# test
downloader = source.get_downloader()
# validation
source.get_cataloger.assert_called_with()
fake_cataloger.get_downloader.assert_called_with(fake_conduit, source.descriptor, url)
self.assertEqual(downloader, fake_downloader)
示例5: test_refresh
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_conduit [as 别名]
def test_refresh(self, fake_urls):
url = 'http://xyz.com'
urls = ['url-1', 'url-2']
fake_urls.__get__ = Mock(return_value=urls)
conduit = Mock()
cataloger = Mock()
cataloger.refresh.side_effect = FakeRefresh()
source = ContentSource('s-1', {constants.BASE_URL: url})
source.get_conduit = Mock(return_value=conduit)
source.get_cataloger = Mock(return_value=cataloger)
# test
report = source.refresh()
# validation
self.assertEqual(conduit.reset.call_count, len(urls))
self.assertEqual(cataloger.refresh.call_count, len(urls))
n = 0
added = 10
deleted = 1
for _url in source.urls:
cataloger.refresh.assert_any(conduit, source.descriptor, _url)
self.assertEqual(report[n].source_id, source.id)
self.assertEqual(report[n].url, _url)
self.assertTrue(report[n].succeeded)
self.assertEqual(report[n].errors, [])
self.assertEqual(report[n].added_count, added)
self.assertEqual(report[n].deleted_count, deleted)
added += 10
deleted += 1
n += 1