當前位置: 首頁>>代碼示例>>Python>>正文


Python rendering.ProgressTracker類代碼示例

本文整理匯總了Python中pulp_node.extensions.admin.rendering.ProgressTracker的典型用法代碼示例。如果您正苦於以下問題:Python ProgressTracker類的具體用法?Python ProgressTracker怎麽用?Python ProgressTracker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ProgressTracker類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_display_with_snapshot

 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')
         ]
     )
開發者ID:credativ,項目名稱:pulp,代碼行數:31,代碼來源:test_admin_extensions.py

示例2: test_display_no_snapshot

 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')
         ]
     )
開發者ID:credativ,項目名稱:pulp,代碼行數:27,代碼來源:test_admin_extensions.py

示例3: test_render_zero_total_and_not_finished

 def test_render_zero_total_and_not_finished(self):
     report = {
         'repo_id': 1,
         'state': 'merging',
         'unit_add': {
             'total': 0,
             'completed': 0,
             'details': ''
         }
     }
     progress_bar = Mock()
     ProgressTracker._render(report, progress_bar)
     progress_bar.render.assert_called_with(0.01, 1)
開發者ID:credativ,項目名稱:pulp,代碼行數:13,代碼來源:test_admin_extensions.py

示例4: test_render_not_adding_units

 def test_render_not_adding_units(self):
     report = {
         'repo_id': 1,
         'state': 'merging',
         'unit_add': {
             'total': 10,
             'completed': 5,
             'details': ''
         }
     }
     progress_bar = Mock()
     ProgressTracker._render(report, progress_bar)
     progress_bar.render.assert_called_with(5, 10, None)
開發者ID:credativ,項目名稱:pulp,代碼行數:13,代碼來源:test_admin_extensions.py

示例5: test_render

 def test_render(self):
     report = {
         'repo_id': 1,
         'state': 'adding_units',
         'unit_add': {
             'total': 10,
             'completed': 5,
             'details': 'http://redhat.com/foo/bar.unit'
         }
     }
     progress_bar = Mock()
     ProgressTracker._render(report, progress_bar)
     progress_bar.render.assert_called_with(5, 10, 'Step: Adding Units\n(5/10) Add unit: bar.unit')
開發者ID:credativ,項目名稱:pulp,代碼行數:13,代碼來源:test_admin_extensions.py

示例6: test_find

 def test_find(self):
     reports = [
         {'repo_id': 1, 'state': 'merging'},
         {'repo_id': 2, 'state': 'merging'},
         {'repo_id': 3, 'state': 'merging'},
     ]
     self.assertEqual(ProgressTracker._find(2, reports), reports[1])
開發者ID:credativ,項目名稱:pulp,代碼行數:7,代碼來源:test_admin_extensions.py

示例7: test_display_no_report

 def test_display_no_report(self):
     fake_prompt = Mock()
     tracker = ProgressTracker(fake_prompt)
     tracker.display({})
開發者ID:credativ,項目名稱:pulp,代碼行數:4,代碼來源:test_admin_extensions.py

示例8: test_display_none

 def test_display_none(self):
     fake_prompt = Mock()
     tracker = ProgressTracker(fake_prompt)
     tracker.display(None)
開發者ID:credativ,項目名稱:pulp,代碼行數:4,代碼來源:test_admin_extensions.py


注:本文中的pulp_node.extensions.admin.rendering.ProgressTracker類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。