/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tests/test_push.py

  • Committer: Curtis Hovey
  • Date: 2012-03-20 12:39:08 UTC
  • mfrom: (776.3.23 gpush-do-push)
  • Revision ID: sinzui.is@verizon.net-20120320123908-lclvaiasu0e50odg
Merged faster push.

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
            (branch, 'lp:~user/fnord/test'), push.do_push.args)
134
134
        self.assertEqual(
135
135
            {'overwrite': True}, push.do_push.kwargs)
 
136
 
 
137
 
 
138
class DoPushTestCase(tests.TestCaseWithTransport):
 
139
 
 
140
    def setup_ui(self):
 
141
        set_ui_factory()
 
142
        progress_panel = ProgressPanel()
 
143
        ui.ui_factory.set_progress_bar_widget(progress_panel)
 
144
        MockMethod.bind(self, progress_panel.pb, 'tick')
 
145
        MockMethod.bind(self, progress_panel.pb, 'update')
 
146
        MockMethod.bind(self, progress_panel.pb, 'finished')
 
147
        return progress_panel
 
148
 
 
149
    def make_from_branch(self):
 
150
        from_tree = self.make_branch_and_tree('this')
 
151
        self.build_tree(['this/a', 'this/b'])
 
152
        from_tree.add(['a', 'b'])
 
153
        from_tree.commit("msg")
 
154
        return from_tree.branch
 
155
 
 
156
    def test_do_push_without_dir(self):
 
157
        progress_panel = self.setup_ui()
 
158
        from_branch = self.make_from_branch()
 
159
        message = push.do_push(from_branch, 'that', False)
 
160
        self.assertEqual('1 revision(s) pushed.', message)
 
161
        self.assertEqual(True, progress_panel.pb.update.called)
 
162
        self.assertEqual(True, progress_panel.pb.finished.called)
 
163
 
 
164
    def test_do_push_without_parent_dir(self):
 
165
        progress_panel = self.setup_ui()
 
166
        from_branch = self.make_from_branch()
 
167
        MockMethod.bind(self, push, 'question_dialog', Gtk.ResponseType.OK)
 
168
        message = push.do_push(from_branch, 'that/there', False)
 
169
        self.assertEqual('1 revision(s) pushed.', message)
 
170
        self.assertEqual(True, push.question_dialog.called)
 
171
        self.assertEqual(True, progress_panel.pb.update.called)
 
172
        self.assertEqual(True, progress_panel.pb.finished.called)
 
173
 
 
174
    def test_do_push_without_parent_dir_aborted(self):
 
175
        self.setup_ui()
 
176
        from_branch = self.make_from_branch()
 
177
        MockMethod.bind(self, push, 'question_dialog', Gtk.ResponseType.CANCEL)
 
178
        message = push.do_push(from_branch, 'that/there', False)
 
179
        self.assertEqual('Push aborted.', message)
 
180
 
 
181
    def test_do_push_with_dir(self):
 
182
        progress_panel = self.setup_ui()
 
183
        self.make_branch_and_tree('that')
 
184
        from_branch = self.make_from_branch()
 
185
        message = push.do_push(from_branch, 'that', False)
 
186
        self.assertEqual('1 revision(s) pushed.', message)
 
187
        self.assertEqual(True, progress_panel.pb.update.called)
 
188
        self.assertEqual(True, progress_panel.pb.finished.called)
 
189
 
 
190
    def test_create_push_result_unstacked(self):
 
191
        from_branch = object()
 
192
        to_branch = self.make_branch_and_tree('that').branch
 
193
        push_result = push.create_push_result(from_branch, to_branch)
 
194
        self.assertIs(from_branch, push_result.source_branch)
 
195
        self.assertIs(to_branch, push_result.target_branch)
 
196
        self.assertIs(None, push_result.branch_push_result)
 
197
        self.assertIs(None, push_result.master_branch)
 
198
        self.assertEqual(0, push_result.old_revno)
 
199
        self.assertEqual(to_branch.last_revision(), push_result.old_revid)
 
200
        self.assertIs(None, push_result.workingtree_updated)
 
201
        self.assertIs(None, push_result.stacked_on)
 
202
 
 
203
    def test_create_push_result_stacked(self):
 
204
        from_branch = object()
 
205
        to_branch = self.make_branch_and_tree('that').branch
 
206
        MockMethod.bind(self, to_branch, 'get_stacked_on_url', 'lp:project')
 
207
        push_result = push.create_push_result(from_branch, to_branch)
 
208
        self.assertEqual('lp:project', push_result.stacked_on)
 
209
 
 
210
    def test_create_push_message_stacked_on(self):
 
211
        from_branch = object()
 
212
        to_branch = self.make_branch_and_tree('that').branch
 
213
        MockMethod.bind(self, to_branch, 'get_stacked_on_url', 'lp:project')
 
214
        push_result = push.create_push_result(from_branch, to_branch)
 
215
        from_branch = self.make_from_branch()
 
216
        message = push.create_push_message(from_branch, push_result)
 
217
        self.assertEqual(
 
218
            '1 revision(s) pushed.\nStacked on lp:project.', message)
 
219
 
 
220
    def test_create_push_message_workingtree_updated_false(self):
 
221
        from_branch = object()
 
222
        to_branch = self.make_branch_and_tree('that').branch
 
223
        push_result = push.create_push_result(from_branch, to_branch)
 
224
        push_result.workingtree_updated = False
 
225
        from_branch = self.make_from_branch()
 
226
        message = push.create_push_message(from_branch, push_result)
 
227
        self.assertEqual(
 
228
            "1 revision(s) pushed.\n\nThe working tree was not updated:\n"
 
229
            "See 'bzr help working-trees' for more information.",
 
230
            message)