本文整理汇总了Python中pulp.server.content.sources.model.ContentSource.get_cataloger方法的典型用法代码示例。如果您正苦于以下问题:Python ContentSource.get_cataloger方法的具体用法?Python ContentSource.get_cataloger怎么用?Python ContentSource.get_cataloger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.content.sources.model.ContentSource
的用法示例。
在下文中一共展示了ContentSource.get_cataloger方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_refresh_canceled
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_cataloger [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, [])
示例2: test_refresh_raised
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_cataloger [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
示例3: test_is_valid_bad_descriptor
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_cataloger [as 别名]
def test_is_valid_bad_descriptor(self, mock_descriptor_is_valid):
source = ContentSource('s-1', {'A': 1})
source.get_downloader = Mock()
source.get_cataloger = Mock()
mock_descriptor_is_valid.side_effect = ValueError()
# Test
valid = source.is_valid()
# validation
self.assertFalse(valid)
示例4: test_cataloger
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_cataloger [as 别名]
def test_cataloger(self, fake_plugins):
plugin = Mock()
fake_plugins.get_cataloger_by_id.return_value = plugin, {}
# test
source = ContentSource('s-1', {constants.TYPE: 1234})
cataloger = source.get_cataloger()
# validation
fake_plugins.get_cataloger_by_id.assert_called_with(1234)
self.assertEqual(plugin, cataloger)
示例5: test_is_valid
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_cataloger [as 别名]
def test_is_valid(self, mock_descriptor_is_valid):
source = ContentSource('s-1', {'A': 1})
source.get_downloader = Mock()
source.get_cataloger = Mock()
# Test
valid = source.is_valid()
# validation
source.get_cataloger.assert_called_with()
source.get_downloader.assert_called_with()
mock_descriptor_is_valid.assert_called_with(source.id, source.descriptor)
self.assertTrue(valid)
示例6: test_is_valid_no_downloader
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_cataloger [as 别名]
def test_is_valid_no_downloader(self, mock_descriptor_is_valid):
source = ContentSource('s-1', {'A': 1})
source.get_downloader = Mock(side_effect=NotImplementedError())
source.get_cataloger = Mock()
# Test
valid = source.is_valid()
# validation
source.get_cataloger.assert_called_with()
source.get_downloader.assert_called_with()
self.assertFalse(mock_descriptor_is_valid.called)
self.assertFalse(valid)
示例7: test_is_valid_no_plugin
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_cataloger [as 别名]
def test_is_valid_no_plugin(self, mock_descriptor_is_valid):
mock_descriptor_is_valid.return_value = True
source = ContentSource("s-1", {"A": 1})
source.get_downloader = Mock()
source.get_cataloger = Mock(side_effect=NotImplementedError())
# Test
valid = source.is_valid()
# validation
source.get_cataloger.assert_called_with()
self.assertFalse(source.get_downloader.called)
self.assertTrue(mock_descriptor_is_valid.called)
self.assertFalse(valid)
示例8: test_downloader
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_cataloger [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)
示例9: test_refresh
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import get_cataloger [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