Beispiel #1
0
 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')
         ]
     )
Beispiel #2
0
 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')
     ])
Beispiel #3
0
 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')
         ]
     )
Beispiel #4
0
 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')
         ]
     )
Beispiel #5
0
 def test_display_no_report(self):
     fake_prompt = Mock()
     tracker = ProgressTracker(fake_prompt)
     tracker.display({})
Beispiel #6
0
 def test_display_none(self):
     fake_prompt = Mock()
     tracker = ProgressTracker(fake_prompt)
     tracker.display(None)
Beispiel #7
0
 def test_display_no_report(self):
     fake_prompt = Mock()
     tracker = ProgressTracker(fake_prompt)
     tracker.display({})
Beispiel #8
0
 def test_display_none(self):
     fake_prompt = Mock()
     tracker = ProgressTracker(fake_prompt)
     tracker.display(None)