Status: | Merged |
---|---|
Merged at revision: | 782 |
Proposed branch: | lp:~sinzui/bzr-gtk/gpush |
Merge into: | lp:bzr-gtk |
Diff against target: |
378 lines (+202/-47) 3 files modified
push.py (+59/-44) tests/__init__.py (+8/-3) tests/test_push.py (+135/-0) |
To merge this branch: | bzr merge lp:~sinzui/bzr-gtk/gpush |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jelmer Vernooij (community) | Approve | ||
Review via email: mp+95769@code.launchpad.net |
Commit message
Description of the change
Integrate the pogress bar and message into the push dialog.
Launchpad bug: https:/
Pre-
This branch replaces the progress dialog with a progress panel and
the info dialog with a message label. When the user choosed to push,
the progress panel is shown, and the message is shown when completed.
-------
RULES
* Add a progress panel and a label to the push dialog that are not
visible until the push starts.
* Update HBox to Box.
* Remove the unused attrs and variables from the code.
* I decided not to remove two unused attributes because it breaks
anything that calls PushDialog. Do we want to change the API?
* Fix the spacing and padding to conform to the GNOME Human
Interface guidelines.
* ADDENDUM: I made a minor change to do_push to return the message
instead of the count. PushResult.__int__ is deprecated. I decided
I want to fix do_push() in my next branch without changing
_
QA
http://
http://
Run this command from a branch with theses changes.
BZR_
- 793. By Curtis Hovey
-
Merged trunk.
- 794. By Curtis Hovey
-
Fixed spelling.
Preview Diff
1 | === modified file 'push.py' | |||
2 | --- push.py 2012-02-27 18:47:21 +0000 | |||
3 | +++ push.py 2012-03-04 02:24:17 +0000 | |||
4 | @@ -1,4 +1,5 @@ | |||
6 | 1 | # Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com> | 1 | # Copyright (C) 2006 by Szilveszter Farkas (Phanatic) |
7 | 2 | # <szilveszter.farkas@gmail.com> | ||
8 | 2 | # Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org> | 3 | # Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org> |
9 | 3 | # | 4 | # |
10 | 4 | # This program is free software; you can redistribute it and/or modify | 5 | # This program is free software; you can redistribute it and/or modify |
11 | @@ -15,20 +16,23 @@ | |||
12 | 15 | # along with this program; if not, write to the Free Software | 16 | # along with this program; if not, write to the Free Software |
13 | 16 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
14 | 17 | 18 | ||
15 | 18 | from gi.repository import GObject | ||
16 | 19 | from gi.repository import Gtk | 19 | from gi.repository import Gtk |
17 | 20 | 20 | ||
18 | 21 | from errors import show_bzr_error | 21 | from errors import show_bzr_error |
19 | 22 | 22 | ||
21 | 23 | import bzrlib.errors as errors | 23 | from bzrlib import ( |
22 | 24 | errors, | ||
23 | 25 | ui, | ||
24 | 26 | ) | ||
25 | 27 | from bzrlib.bzrdir import BzrDir | ||
26 | 28 | from bzrlib.transport import get_transport | ||
27 | 24 | 29 | ||
28 | 25 | from bzrlib.plugins.gtk.dialog import ( | 30 | from bzrlib.plugins.gtk.dialog import ( |
29 | 26 | info_dialog, | ||
30 | 27 | question_dialog, | 31 | question_dialog, |
31 | 28 | ) | 32 | ) |
32 | 29 | |||
33 | 30 | from bzrlib.plugins.gtk.history import UrlHistory | 33 | from bzrlib.plugins.gtk.history import UrlHistory |
34 | 31 | from bzrlib.plugins.gtk.i18n import _i18n | 34 | from bzrlib.plugins.gtk.i18n import _i18n |
35 | 35 | from bzrlib.plugins.gtk.ui import ProgressPanel | ||
36 | 32 | 36 | ||
37 | 33 | 37 | ||
38 | 34 | class PushDialog(Gtk.Dialog): | 38 | class PushDialog(Gtk.Dialog): |
39 | @@ -37,39 +41,43 @@ | |||
40 | 37 | def __init__(self, repository, revid, branch=None, parent=None): | 41 | def __init__(self, repository, revid, branch=None, parent=None): |
41 | 38 | """Initialize the Push dialog. """ | 42 | """Initialize the Push dialog. """ |
42 | 39 | super(PushDialog, self).__init__( | 43 | super(PushDialog, self).__init__( |
48 | 40 | title="Push", parent=parent, flags=0, | 44 | title="Push", parent=parent, flags=0, border_width=6, |
49 | 41 | buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) | 45 | buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)) |
50 | 42 | 46 | self.branch = branch | |
51 | 43 | 47 | ||
52 | 44 | # Get arguments | 48 | # Unused arguments |
53 | 45 | self.repository = repository | 49 | self.repository = repository |
54 | 46 | self.revid = revid | 50 | self.revid = revid |
55 | 47 | self.branch = branch | ||
56 | 48 | 51 | ||
57 | 49 | # Create the widgets | 52 | # Create the widgets |
58 | 50 | self._label_location = Gtk.Label(label=_i18n("Location:")) | 53 | self._label_location = Gtk.Label(label=_i18n("Location:")) |
59 | 51 | self._combo = Gtk.ComboBox.new_with_entry() | 54 | self._combo = Gtk.ComboBox.new_with_entry() |
60 | 52 | self._button_push = Gtk.Button(_i18n("_Push"), use_underline=True) | 55 | self._button_push = Gtk.Button(_i18n("_Push"), use_underline=True) |
62 | 53 | self._hbox_location = Gtk.HBox() | 56 | self._hbox_location = Gtk.Box(Gtk.Orientation.HORIZONTAL, 6) |
63 | 57 | self._push_message = Gtk.Label(xalign=0) | ||
64 | 58 | self._progress_widget = ProgressPanel() | ||
65 | 54 | 59 | ||
66 | 55 | # Set callbacks | 60 | # Set callbacks |
67 | 61 | ui.ui_factory.set_progress_bar_widget(self._progress_widget) | ||
68 | 62 | self.connect('close', self._on_close_clicked) | ||
69 | 56 | self._button_push.connect('clicked', self._on_push_clicked) | 63 | self._button_push.connect('clicked', self._on_push_clicked) |
70 | 57 | 64 | ||
71 | 58 | # Set properties | 65 | # Set properties |
75 | 59 | self._label_location.set_alignment(0, 0.5) | 66 | content_area = self.get_content_area() |
76 | 60 | self._hbox_location.set_spacing(3) | 67 | content_area.set_spacing(6) |
74 | 61 | self.get_content_area().set_spacing(3) | ||
77 | 62 | 68 | ||
78 | 63 | # Pack widgets | 69 | # Pack widgets |
84 | 64 | self._hbox_location.pack_start( | 70 | self._hbox_location.pack_start(self._label_location, False, False, 0) |
85 | 65 | self._label_location, False, False, 0) | 71 | self._hbox_location.pack_start(self._combo, False, False, 0) |
86 | 66 | self._hbox_location.pack_start(self._combo, True, True, 0) | 72 | content_area.pack_start(self._hbox_location, True, True, 0) |
87 | 67 | self.get_content_area().pack_start(self._hbox_location, True, True, 0) | 73 | content_area.pack_start(self._progress_widget, True, True, 0) |
88 | 68 | # XXX sinzui 2011-08-12: maybe False, False, 0 | 74 | content_area.pack_start(self._push_message, True, True, 0) |
89 | 69 | self.get_action_area().pack_end(self._button_push, True, True, 0) | 75 | self.get_action_area().pack_end(self._button_push, True, True, 0) |
90 | 70 | 76 | ||
91 | 71 | # Show the dialog | 77 | # Show the dialog |
93 | 72 | self.get_content_area().show_all() | 78 | content_area.show_all() |
94 | 79 | self._progress_widget.hide() | ||
95 | 80 | self._push_message.hide() | ||
96 | 73 | 81 | ||
97 | 74 | # Build location history | 82 | # Build location history |
98 | 75 | self._history = UrlHistory(self.branch.get_config(), 'push_history') | 83 | self._history = UrlHistory(self.branch.get_config(), 'push_history') |
99 | @@ -79,7 +87,7 @@ | |||
100 | 79 | """Build up the location history. """ | 87 | """Build up the location history. """ |
101 | 80 | self._combo_model = Gtk.ListStore(str) | 88 | self._combo_model = Gtk.ListStore(str) |
102 | 81 | for item in self._history.get_entries(): | 89 | for item in self._history.get_entries(): |
104 | 82 | self._combo_model.append([ item ]) | 90 | self._combo_model.append([item]) |
105 | 83 | self._combo.set_model(self._combo_model) | 91 | self._combo.set_model(self._combo_model) |
106 | 84 | self._combo.set_entry_text_column(0) | 92 | self._combo.set_entry_text_column(0) |
107 | 85 | 93 | ||
108 | @@ -88,28 +96,36 @@ | |||
109 | 88 | if location is not None: | 96 | if location is not None: |
110 | 89 | self._combo.get_child().set_text(location) | 97 | self._combo.get_child().set_text(location) |
111 | 90 | 98 | ||
112 | 99 | def _on_close_clicked(self, widget): | ||
113 | 100 | """Close dialog handler.""" | ||
114 | 101 | ui.ui_factory.set_progress_bar_widget(None) | ||
115 | 102 | |||
116 | 91 | @show_bzr_error | 103 | @show_bzr_error |
117 | 92 | def _on_push_clicked(self, widget): | 104 | def _on_push_clicked(self, widget): |
118 | 93 | """Push button clicked handler. """ | 105 | """Push button clicked handler. """ |
119 | 106 | self._push_message.hide() | ||
120 | 107 | self._progress_widget.tick() | ||
121 | 94 | location = self._combo.get_child().get_text() | 108 | location = self._combo.get_child().get_text() |
122 | 95 | revs = 0 | ||
123 | 96 | 109 | ||
124 | 97 | try: | 110 | try: |
126 | 98 | revs = do_push(self.branch, location=location, overwrite=False) | 111 | message = do_push(self.branch, location, overwrite=False) |
127 | 99 | except errors.DivergedBranches: | 112 | except errors.DivergedBranches: |
130 | 100 | response = question_dialog(_i18n('Branches have been diverged'), | 113 | response = question_dialog( |
131 | 101 | _i18n('You cannot push if branches have diverged.\nOverwrite?')) | 114 | _i18n('Branches have been diverged'), |
132 | 115 | _i18n('You cannot push if branches have diverged.\n' | ||
133 | 116 | 'Overwrite?')) | ||
134 | 102 | if response == Gtk.ResponseType.YES: | 117 | if response == Gtk.ResponseType.YES: |
138 | 103 | revs = do_push(self.branch, location=location, overwrite=True) | 118 | message = do_push(self.branch, location, overwrite=True) |
139 | 104 | 119 | else: | |
140 | 105 | if self.branch is not None and self.branch.get_push_location() is None: | 120 | return |
141 | 121 | self._history.add_entry(location) | ||
142 | 122 | if (self.branch is not None | ||
143 | 123 | and self.branch.get_push_location() is None): | ||
144 | 106 | self.branch.set_push_location(location) | 124 | self.branch.set_push_location(location) |
151 | 107 | 125 | if message: | |
152 | 108 | self._history.add_entry(location) | 126 | self._progress_widget.finished() |
153 | 109 | info_dialog(_i18n('Push successful'), | 127 | self._push_message.props.label = message |
154 | 110 | _i18n("%d revision(s) pushed.") % revs) | 128 | self._push_message.show() |
149 | 111 | |||
150 | 112 | self.response(Gtk.ResponseType.OK) | ||
155 | 113 | 129 | ||
156 | 114 | 130 | ||
157 | 115 | def do_push(br_from, location, overwrite): | 131 | def do_push(br_from, location, overwrite): |
158 | @@ -120,14 +136,9 @@ | |||
159 | 120 | :param overwrite: overwrite target location if it diverged | 136 | :param overwrite: overwrite target location if it diverged |
160 | 121 | :return: number of revisions pushed | 137 | :return: number of revisions pushed |
161 | 122 | """ | 138 | """ |
162 | 123 | from bzrlib.bzrdir import BzrDir | ||
163 | 124 | from bzrlib.transport import get_transport | ||
164 | 125 | |||
165 | 126 | transport = get_transport(location) | 139 | transport = get_transport(location) |
166 | 127 | location_url = transport.base | 140 | location_url = transport.base |
167 | 128 | 141 | ||
168 | 129 | old_rh = [] | ||
169 | 130 | |||
170 | 131 | try: | 142 | try: |
171 | 132 | dir_to = BzrDir.open(location_url) | 143 | dir_to = BzrDir.open(location_url) |
172 | 133 | br_to = dir_to.open_branch() | 144 | br_to = dir_to.open_branch() |
173 | @@ -138,8 +149,10 @@ | |||
174 | 138 | relurl = transport.relpath(location_url) | 149 | relurl = transport.relpath(location_url) |
175 | 139 | transport.mkdir(relurl) | 150 | transport.mkdir(relurl) |
176 | 140 | except errors.NoSuchFile: | 151 | except errors.NoSuchFile: |
179 | 141 | response = question_dialog(_i18n('Non existing parent directory'), | 152 | response = question_dialog( |
180 | 142 | _i18n("The parent directory (%s)\ndoesn't exist. Create?") % location) | 153 | _i18n('Non existing parent directory'), |
181 | 154 | _i18n("The parent directory (%s)\ndoesn't exist. Create?") % | ||
182 | 155 | location) | ||
183 | 143 | if response == Gtk.ResponseType.OK: | 156 | if response == Gtk.ResponseType.OK: |
184 | 144 | transport.create_prefix() | 157 | transport.create_prefix() |
185 | 145 | else: | 158 | else: |
186 | @@ -149,7 +162,7 @@ | |||
187 | 149 | br_to = dir_to.open_branch() | 162 | br_to = dir_to.open_branch() |
188 | 150 | count = len(br_to.revision_history()) | 163 | count = len(br_to.revision_history()) |
189 | 151 | else: | 164 | else: |
191 | 152 | old_rh = br_to.revision_history() | 165 | br_to.revision_history() |
192 | 153 | try: | 166 | try: |
193 | 154 | tree_to = dir_to.open_workingtree() | 167 | tree_to = dir_to.open_workingtree() |
194 | 155 | except errors.NotLocalUrl: | 168 | except errors.NotLocalUrl: |
195 | @@ -160,4 +173,6 @@ | |||
196 | 160 | else: | 173 | else: |
197 | 161 | count = tree_to.pull(br_from, overwrite) | 174 | count = tree_to.pull(br_from, overwrite) |
198 | 162 | 175 | ||
200 | 163 | return count | 176 | # The count var is either an int or a PushResult. PushResult is being |
201 | 177 | # coerced into an int, but the method is deprecated. | ||
202 | 178 | return _i18n("%d revision(s) pushed.") % int(count) | ||
203 | 164 | 179 | ||
204 | === modified file 'tests/__init__.py' | |||
205 | --- tests/__init__.py 2012-02-28 17:52:54 +0000 | |||
206 | +++ tests/__init__.py 2012-03-04 02:24:17 +0000 | |||
207 | @@ -46,23 +46,28 @@ | |||
208 | 46 | class MockMethod(object): | 46 | class MockMethod(object): |
209 | 47 | 47 | ||
210 | 48 | @classmethod | 48 | @classmethod |
212 | 49 | def bind(klass, test_instance, obj, method_name, return_value=None): | 49 | def bind(klass, test_instance, obj, method_name, |
213 | 50 | return_value=None, raise_error=None, raise_on=1): | ||
214 | 50 | original_method = getattr(obj, method_name) | 51 | original_method = getattr(obj, method_name) |
215 | 51 | test_instance.addCleanup(setattr, obj, method_name, original_method) | 52 | test_instance.addCleanup(setattr, obj, method_name, original_method) |
217 | 52 | setattr(obj, method_name, klass(return_value)) | 53 | setattr(obj, method_name, klass(return_value, raise_error, raise_on)) |
218 | 53 | 54 | ||
220 | 54 | def __init__(self, return_value=None): | 55 | def __init__(self, return_value=None, raise_error=None, raise_on=1): |
221 | 55 | self.called = False | 56 | self.called = False |
222 | 56 | self.call_count = 0 | 57 | self.call_count = 0 |
223 | 57 | self.args = None | 58 | self.args = None |
224 | 58 | self.kwargs = None | 59 | self.kwargs = None |
225 | 59 | self.return_value = return_value | 60 | self.return_value = return_value |
226 | 61 | self.raise_error = raise_error | ||
227 | 62 | self.raise_on = raise_on | ||
228 | 60 | 63 | ||
229 | 61 | def __call__(self, *args, **kwargs): | 64 | def __call__(self, *args, **kwargs): |
230 | 62 | self.called = True | 65 | self.called = True |
231 | 63 | self.call_count += 1 | 66 | self.call_count += 1 |
232 | 64 | self.args = args | 67 | self.args = args |
233 | 65 | self.kwargs = kwargs | 68 | self.kwargs = kwargs |
234 | 69 | if self.raise_error is not None and self.call_count == self.raise_on: | ||
235 | 70 | raise self.raise_error | ||
236 | 66 | return self.return_value | 71 | return self.return_value |
237 | 67 | 72 | ||
238 | 68 | 73 | ||
239 | 69 | 74 | ||
240 | === added file 'tests/test_push.py' | |||
241 | --- tests/test_push.py 1970-01-01 00:00:00 +0000 | |||
242 | +++ tests/test_push.py 2012-03-04 02:24:17 +0000 | |||
243 | @@ -0,0 +1,135 @@ | |||
244 | 1 | # Copyright (C) 2012 Curtis Hovey <sinzui.is@verizon.net> | ||
245 | 2 | # | ||
246 | 3 | # This program is free software; you can redistribute it and/or modify | ||
247 | 4 | # it under the terms of the GNU General Public License as published by | ||
248 | 5 | # the Free Software Foundation; either version 2 of the License, or | ||
249 | 6 | # (at your option) any later version. | ||
250 | 7 | # | ||
251 | 8 | # This program is distributed in the hope that it will be useful, | ||
252 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
253 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
254 | 11 | # GNU General Public License for more details. | ||
255 | 12 | # | ||
256 | 13 | # You should have received a copy of the GNU General Public License | ||
257 | 14 | # along with this program; if not, write to the Free Software | ||
258 | 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
259 | 16 | |||
260 | 17 | """Test the ui functionality.""" | ||
261 | 18 | |||
262 | 19 | from gi.repository import Gtk | ||
263 | 20 | |||
264 | 21 | from bzrlib import ( | ||
265 | 22 | errors, | ||
266 | 23 | tests, | ||
267 | 24 | ui, | ||
268 | 25 | ) | ||
269 | 26 | |||
270 | 27 | from bzrlib.plugins.gtk import ( | ||
271 | 28 | push, | ||
272 | 29 | set_ui_factory, | ||
273 | 30 | ) | ||
274 | 31 | from bzrlib.plugins.gtk.tests import MockMethod | ||
275 | 32 | from bzrlib.plugins.gtk.history import UrlHistory | ||
276 | 33 | from bzrlib.plugins.gtk.ui import ProgressPanel | ||
277 | 34 | |||
278 | 35 | |||
279 | 36 | class PushTestCase(tests.TestCaseWithMemoryTransport): | ||
280 | 37 | |||
281 | 38 | def make_push_branch(self): | ||
282 | 39 | tree = self.make_branch_and_memory_tree('test') | ||
283 | 40 | return tree.branch | ||
284 | 41 | |||
285 | 42 | def test_init(self): | ||
286 | 43 | set_ui_factory() | ||
287 | 44 | branch = self.make_push_branch() | ||
288 | 45 | dialog = push.PushDialog( | ||
289 | 46 | repository=None, revid=None, branch=branch, parent=None) | ||
290 | 47 | self.assertIs(None, dialog.props.parent) | ||
291 | 48 | self.assertIs(None, dialog.repository) | ||
292 | 49 | self.assertIs(None, dialog.revid) | ||
293 | 50 | self.assertIs(branch, dialog.branch) | ||
294 | 51 | # Layout rules to match HIG. | ||
295 | 52 | self.assertIsInstance(dialog._label_location, Gtk.Label) | ||
296 | 53 | self.assertIsInstance(dialog._combo, Gtk.ComboBox) | ||
297 | 54 | self.assertIsInstance(dialog._button_push, Gtk.Button) | ||
298 | 55 | self.assertIsInstance(dialog._hbox_location, Gtk.Box) | ||
299 | 56 | self.assertIsInstance(dialog._progress_widget, ProgressPanel) | ||
300 | 57 | self.assertIsInstance(dialog._push_message, Gtk.Label) | ||
301 | 58 | self.assertIsInstance(dialog._history, UrlHistory) | ||
302 | 59 | self.assertIs( | ||
303 | 60 | ui.ui_factory._progress_bar_widget, dialog._progress_widget) | ||
304 | 61 | self.assertEqual( | ||
305 | 62 | Gtk.Orientation.HORIZONTAL, | ||
306 | 63 | dialog._hbox_location.props.orientation) | ||
307 | 64 | self.assertEqual(0.0, dialog._push_message.props.xalign) | ||
308 | 65 | self.assertEqual(6, dialog.props.border_width) | ||
309 | 66 | self.assertEqual(6, dialog._hbox_location.props.spacing) | ||
310 | 67 | self.assertEqual(6, dialog.get_content_area().props.spacing) | ||
311 | 68 | # Show rules. | ||
312 | 69 | self.assertIs(True, dialog._combo.props.visible) | ||
313 | 70 | self.assertIs(False, dialog._progress_widget.props.visible) | ||
314 | 71 | self.assertIs(False, dialog._push_message.props.visible) | ||
315 | 72 | |||
316 | 73 | def test_build_history(self): | ||
317 | 74 | set_ui_factory() | ||
318 | 75 | branch = self.make_push_branch() | ||
319 | 76 | branch.set_push_location('lp:~user/fnord/trunk') | ||
320 | 77 | dialog = push.PushDialog(None, None, branch) | ||
321 | 78 | dialog._history.add_entry('lp:~user/fnord/test1') | ||
322 | 79 | dialog._history.add_entry('lp:~user/fnord/test2') | ||
323 | 80 | dialog._build_history() | ||
324 | 81 | self.assertEqual( | ||
325 | 82 | 'lp:~user/fnord/trunk', dialog._combo.get_child().props.text) | ||
326 | 83 | self.assertIsInstance(dialog._combo_model, Gtk.ListStore) | ||
327 | 84 | self.assertIs(dialog._combo.get_model(), dialog._combo_model) | ||
328 | 85 | locations = [row[0] for row in dialog._combo_model] | ||
329 | 86 | self.assertEqual( | ||
330 | 87 | ['lp:~user/fnord/test1', 'lp:~user/fnord/test2'], locations) | ||
331 | 88 | |||
332 | 89 | def test_on_close_clicked(self): | ||
333 | 90 | # The ui_factory's progress bar widget is set to None. | ||
334 | 91 | set_ui_factory() | ||
335 | 92 | branch = self.make_push_branch() | ||
336 | 93 | dialog = push.PushDialog(None, None, branch) | ||
337 | 94 | dialog._on_close_clicked(None) | ||
338 | 95 | self.assertIs(None, ui.ui_factory._progress_bar_widget) | ||
339 | 96 | |||
340 | 97 | def test_on_push_clicked_without_errors(self): | ||
341 | 98 | # Verify the dialog's and branch's final states after a push. | ||
342 | 99 | MockMethod.bind(self, push, 'do_push', "test success") | ||
343 | 100 | set_ui_factory() | ||
344 | 101 | branch = self.make_push_branch() | ||
345 | 102 | dialog = push.PushDialog(None, None, branch) | ||
346 | 103 | MockMethod.bind(self, dialog._progress_widget, 'tick') | ||
347 | 104 | dialog._combo.get_child().props.text = 'lp:~user/fnord/test' | ||
348 | 105 | dialog._on_push_clicked(None) | ||
349 | 106 | self.assertIs(True, dialog._progress_widget.tick.called) | ||
350 | 107 | self.assertIs(False, dialog._progress_widget.props.visible) | ||
351 | 108 | self.assertIs(True, push.do_push.called) | ||
352 | 109 | self.assertEqual( | ||
353 | 110 | (branch, 'lp:~user/fnord/test'), push.do_push.args) | ||
354 | 111 | self.assertEqual( | ||
355 | 112 | {'overwrite': False}, push.do_push.kwargs) | ||
356 | 113 | self.assertIs(True, dialog._push_message.props.visible) | ||
357 | 114 | self.assertEqual('test success', dialog._push_message.props.label) | ||
358 | 115 | self.assertEqual( | ||
359 | 116 | 'lp:~user/fnord/test', dialog._history.get_entries()[-1]) | ||
360 | 117 | self.assertEqual('lp:~user/fnord/test', branch.get_push_location()) | ||
361 | 118 | |||
362 | 119 | def test_on_push_clicked_with_divered_branches(self): | ||
363 | 120 | # Verify that when DivergedBranches is raise, the user can choose | ||
364 | 121 | # to overwrite the branch. | ||
365 | 122 | error = errors.DivergedBranches(None, None) | ||
366 | 123 | MockMethod.bind(self, push, 'do_push', raise_error=error) | ||
367 | 124 | MockMethod.bind(self, push, 'question_dialog', Gtk.ResponseType.YES) | ||
368 | 125 | set_ui_factory() | ||
369 | 126 | branch = self.make_push_branch() | ||
370 | 127 | dialog = push.PushDialog(None, None, branch) | ||
371 | 128 | dialog._combo.get_child().props.text = 'lp:~user/fnord/test' | ||
372 | 129 | dialog._on_push_clicked(None) | ||
373 | 130 | self.assertIs(True, push.do_push.called) | ||
374 | 131 | self.assertEqual(2, push.do_push.call_count) | ||
375 | 132 | self.assertEqual( | ||
376 | 133 | (branch, 'lp:~user/fnord/test'), push.do_push.args) | ||
377 | 134 | self.assertEqual( | ||
378 | 135 | {'overwrite': True}, push.do_push.kwargs) |
Thanks, very nice.