38
38
from bzrlib.trace import mutter
39
39
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
43
class CapturingUIFactory(ui.UIFactory):
44
"""A UI Factory for testing - capture the updates made through it."""
47
super(CapturingUIFactory, self).__init__()
52
"""See progress.ProgressTask.clear()."""
55
"""See progress.ProgressTask.clear_term()."""
58
"""See progress.ProgressTask.finished()."""
61
def note(self, fmt_string, *args, **kwargs):
62
"""See progress.ProgressTask.note()."""
64
def progress_bar(self):
67
def nested_progress_bar(self):
71
def update(self, message, count=None, total=None):
72
"""See progress.ProgressTask.update()."""
74
self._calls.append(("update", count, total, message))
77
class TestCapturingUI(TestCase):
79
def test_nested_ignore_depth_beyond_one(self):
80
# we only want to capture the first level out progress, not
81
# want sub-components might do. So we have nested bars ignored.
82
factory = CapturingUIFactory()
83
pb1 = factory.nested_progress_bar()
84
pb1.update('foo', 0, 1)
85
pb2 = factory.nested_progress_bar()
86
pb2.update('foo', 0, 1)
89
self.assertEqual([("update", 0, 1, 'foo')], factory._calls)
41
from bzrlib.tests.testui import ProgressRecordingUIFactory
92
44
class TestCommit(TestCaseWithWorkingTree):
509
461
super(TestCommitProgress, self).setUp()
510
ui.ui_factory = CapturingUIFactory()
462
ui.ui_factory = ProgressRecordingUIFactory()
512
464
def test_commit_progress_steps(self):
513
465
# during commit we one progress update for every entry in the
527
479
# set a progress bar that captures the calls so we can see what is
529
factory = CapturingUIFactory()
481
factory = ProgressRecordingUIFactory()
530
482
ui.ui_factory = factory
531
483
# TODO RBC 20060421 it would be nice to merge the reporter output
532
484
# into the factory for this test - just make the test ui factory
547
499
tree = self.make_branch_and_tree('.')
548
500
# set a progress bar that captures the calls so we can see what is
550
factory = CapturingUIFactory()
502
factory = ProgressRecordingUIFactory()
551
503
ui.ui_factory = factory
552
504
def a_hook(_, _2, _3, _4, _5, _6):
570
522
tree = self.make_branch_and_tree('.')
571
523
# set a progress bar that captures the calls so we can see what is
573
factory = CapturingUIFactory()
525
factory = ProgressRecordingUIFactory()
574
526
ui.ui_factory = factory
575
527
def a_hook(_, _2, _3, _4, _5, _6, _7, _8):