/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-11 15:50:43 UTC
  • mto: This revision was merged to the branch mainline in revision 788.
  • Revision ID: sinzui.is@verizon.net-20120311155043-qzid1sly6hoqnbyi
Add test coverage for do_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 PushTestCase(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(False, progress_panel.pb.tick.called)
 
162
        self.assertEqual(True, progress_panel.pb.update.called)
 
163
        self.assertEqual(True, progress_panel.pb.finished.called)
 
164
 
 
165
    def test_do_push_without_parent_dir(self):
 
166
        progress_panel = self.setup_ui()
 
167
        from_branch = self.make_from_branch()
 
168
        MockMethod.bind(self, push, 'question_dialog', Gtk.ResponseType.OK)
 
169
        message = push.do_push(from_branch, 'that/there', False)
 
170
        self.assertEqual('1 revision(s) pushed.', message)
 
171
        self.assertEqual(True, push.question_dialog.called)
 
172
        self.assertEqual(False, progress_panel.pb.tick.called)
 
173
        self.assertEqual(True, progress_panel.pb.update.called)
 
174
        self.assertEqual(True, progress_panel.pb.finished.called)
 
175
 
 
176
    def test_do_push_with_dir(self):
 
177
        progress_panel = self.setup_ui()
 
178
        self.make_branch_and_tree('that')
 
179
        from_branch = self.make_from_branch()
 
180
        message = push.do_push(from_branch, 'that', False)
 
181
        self.assertEqual('1 revision(s) pushed.', message)
 
182
        self.assertEqual(False, progress_panel.pb.tick.called)
 
183
        self.assertEqual(True, progress_panel.pb.update.called)
 
184
        self.assertEqual(True, progress_panel.pb.finished.called)