本文整理汇总了Python中pulp_node.extensions.admin.rendering.ProgressTracker.display方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressTracker.display方法的具体用法?Python ProgressTracker.display怎么用?Python ProgressTracker.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp_node.extensions.admin.rendering.ProgressTracker
的用法示例。
在下文中一共展示了ProgressTracker.display方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_display_with_snapshot
# 需要导入模块: from pulp_node.extensions.admin.rendering import ProgressTracker [as 别名]
# 或者: from pulp_node.extensions.admin.rendering.ProgressTracker import display [as 别名]
def test_display_with_snapshot(self):
reports = [
{'repo_id': 1, 'state': 'import_finished'},
{'repo_id': 2, 'state': 'import_finished'},
{'repo_id': 3, 'state': 'import_finished'},
{'repo_id': 4, 'state': 'import_finished'},
{'repo_id': 5, 'state': 'import_finished'},
{'repo_id': 6, 'state': 'merging'},
]
report = {
'progress': reports
}
mock_prompt = Mock()
snapshot = [(r, Mock()) for r in reports]
mock_prompt.create_progress_bar.side_effect = [s[1] for s in snapshot[3:]]
tracker = ProgressTracker(mock_prompt)
tracker.snapshot = snapshot[:3]
tracker._render = Mock()
tracker.display(report)
self.assertEqual(tracker.snapshot, snapshot)
tracker._render.assert_has_calls([call(r, pb) for r, pb in snapshot[3:]])
mock_prompt.write.assert_has_calls(
[
call('\n'),
call('(4/6) Repository: 4'),
call('\n'),
call('(5/6) Repository: 5'),
call('\n'),
call('(6/6) Repository: 6')
]
)
示例2: test_display_no_snapshot
# 需要导入模块: from pulp_node.extensions.admin.rendering import ProgressTracker [as 别名]
# 或者: from pulp_node.extensions.admin.rendering.ProgressTracker import display [as 别名]
def test_display_no_snapshot(self):
reports = [
{'repo_id': 1, 'state': 'merging'},
{'repo_id': 2, 'state': 'merging'},
{'repo_id': 3, 'state': 'merging'},
]
report = {
'progress': reports
}
mock_prompt = Mock()
snapshot = [(r, Mock()) for r in reports]
mock_prompt.create_progress_bar.side_effect = [s[1] for s in snapshot]
tracker = ProgressTracker(mock_prompt)
tracker._render = Mock()
tracker.display(report)
self.assertEqual(tracker.snapshot, snapshot)
tracker._render.assert_has_calls([call(r, pb) for r, pb in snapshot])
mock_prompt.write.assert_has_calls(
[
call('\n'),
call('(1/3) Repository: 1'),
call('\n'),
call('(2/3) Repository: 2'),
call('\n'),
call('(3/3) Repository: 3')
]
)
示例3: test_display_no_report
# 需要导入模块: from pulp_node.extensions.admin.rendering import ProgressTracker [as 别名]
# 或者: from pulp_node.extensions.admin.rendering.ProgressTracker import display [as 别名]
def test_display_no_report(self):
fake_prompt = Mock()
tracker = ProgressTracker(fake_prompt)
tracker.display({})
示例4: test_display_none
# 需要导入模块: from pulp_node.extensions.admin.rendering import ProgressTracker [as 别名]
# 或者: from pulp_node.extensions.admin.rendering.ProgressTracker import display [as 别名]
def test_display_none(self):
fake_prompt = Mock()
tracker = ProgressTracker(fake_prompt)
tracker.display(None)