bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1551.2.27
by Aaron Bentley
Got propogation under test |
1 |
# Copyright (C) 2006 by Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
from bzrlib.progress import DummyProgress, ChildProgress |
|
18 |
from bzrlib.tests import TestCase |
|
19 |
||
20 |
class TestProgress(TestCase): |
|
21 |
def setUp(self): |
|
22 |
self.top = ChildProgress(stack=[DummyProgress()]) |
|
23 |
||
24 |
def test_propogation(self): |
|
25 |
self.top.update('foobles', 1, 2) |
|
26 |
self.assertEqual(self.top.message, 'foobles') |
|
27 |
self.assertEqual(self.top.current, 1) |
|
28 |
self.assertEqual(self.top.total, 2) |
|
29 |
self.assertEqual(self.top.child_fraction, 0) |
|
30 |
child = ChildProgress(stack=[self.top]) |
|
31 |
child.update('baubles', 2, 4) |
|
32 |
self.assertEqual(self.top.message, 'foobles') |
|
33 |
self.assertEqual(self.top.current, 1) |
|
34 |
self.assertEqual(self.top.total, 2) |
|
35 |
self.assertEqual(self.top.child_fraction, 0.5) |
|
36 |
grandchild = ChildProgress(stack=[child]) |
|
37 |
grandchild.update('barbells', 1, 2) |
|
38 |
self.assertEqual(self.top.child_fraction, 0.625) |
|
39 |
self.assertEqual(child.child_fraction, 0.5) |
|
40 |
child.update('baubles', 3, 4) |
|
41 |
self.assertEqual(child.child_fraction, 0) |
|
42 |
self.assertEqual(self.top.child_fraction, 0.75) |
|
43 |
grandchild.update('barbells', 1, 2) |
|
44 |
self.assertEqual(self.top.child_fraction, 0.875) |
|
45 |
grandchild.update('barbells', 2, 2) |
|
46 |
self.assertEqual(self.top.child_fraction, 1) |
|
47 |
child.update('baubles', 4, 4) |
|
48 |
self.assertEqual(self.top.child_fraction, 1) |
|
49 |
#test clamping
|
|
50 |
grandchild.update('barbells', 2, 2) |
|
51 |
self.assertEqual(self.top.child_fraction, 1) |