本文整理汇总了Python中pulp.server.content.sources.model.ContentSource.refresh方法的典型用法代码示例。如果您正苦于以下问题:Python ContentSource.refresh方法的具体用法?Python ContentSource.refresh怎么用?Python ContentSource.refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.content.sources.model.ContentSource
的用法示例。
在下文中一共展示了ContentSource.refresh方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_refresh_canceled
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import refresh [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 refresh [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_forced_refresh
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import refresh [as 别名]
def test_forced_refresh(self, fake_manager, fake_load):
sources = {}
for n in range(3):
s = ContentSource('s-%d' % n, {})
s.refresh = Mock()
sources[s.id] = s
fake_manager().has_entries.return_value = True
fake_load.return_value = sources
# test
container = ContentContainer('')
container.refresh(force=True)
# validation
for s in sources.values():
s.refresh.assert_called_with()
示例4: test_refresh_canceled
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import refresh [as 别名]
def test_refresh_canceled(self, fake_load):
sources = {}
for n in range(3):
s = ContentSource('s-%d' % n, {})
s.refresh = Mock()
sources[s.id] = s
fake_load.return_value = sources
# test
canceled = FakeEvent()
canceled.set()
container = ContentContainer('')
container.refresh(canceled, force=True)
# validation
for s in sources.values():
self.assertFalse(s.refresh.called)
示例5: test_refresh
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import refresh [as 别名]
def test_refresh(self, fake_manager, fake_load):
sources = {}
for n in range(3):
s = ContentSource('s-%d' % n, {})
s.refresh = Mock(return_value=[n])
s.get_downloader = Mock()
sources[s.id] = s
fake_manager().has_entries.return_value = False
fake_load.return_value = sources
# test
container = ContentContainer('')
report = container.refresh()
# validation
for s in sources.values():
s.refresh.assert_called_with()
self.assertEqual(sorted(report), [0, 1, 2])
示例6: test_refresh_raised
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import refresh [as 别名]
def test_refresh_raised(self, fake_manager, fake_load):
sources = {}
for n in range(3):
s = ContentSource('s-%d' % n, {})
s.refresh = Mock(side_effect=ValueError('must be int'))
s.get_downloader = Mock()
sources[s.id] = s
fake_manager().has_entries.return_value = False
fake_load.return_value = sources
# test
container = ContentContainer('')
report = container.refresh()
# validation
for s in sources.values():
s.refresh.assert_called_with()
for r in report:
r.errors = ['must be int']
示例7: test_refresh
# 需要导入模块: from pulp.server.content.sources.model import ContentSource [as 别名]
# 或者: from pulp.server.content.sources.model.ContentSource import refresh [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