/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_commit.py

  • Committer: Curtis Hovey
  • Date: 2012-01-22 14:25:39 UTC
  • mto: This revision was merged to the branch mainline in revision 770.
  • Revision ID: sinzui.is@verizon.net-20120122142539-206drnt802c7xpfi
Define _last_selected_file in init so that async signal callbacks can use it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    commit,
36
36
    commitmsgs,
37
37
    )
 
38
from bzrlib.plugins.gtk.commitmsgs import SavedCommitMessagesManager
38
39
 
39
40
 
40
41
# TODO: All we need is basic ancestry code to test this, we shouldn't need a
142
143
        pass # With no widgets, there are no widgets to fill out
143
144
 
144
145
 
 
146
class MockMethod():
 
147
 
 
148
    @classmethod
 
149
    def bind(klass, test_instance, obj, method_name):
 
150
        original_method = getattr(obj, method_name)
 
151
        test_instance.addCleanup(setattr, obj, method_name, original_method)
 
152
        setattr(obj, method_name, klass())
 
153
 
 
154
    def __init__(self):
 
155
        self.called = False
 
156
        self.args = None
 
157
        self.kwargs = None
 
158
 
 
159
    def __call__(self, *args, **kwargs):
 
160
        self.called = True
 
161
        self.args = args
 
162
        self.kwargs = kwargs
 
163
 
 
164
 
145
165
class TestCommitDialogSimple(tests.TestCaseWithTransport):
146
166
 
 
167
    def test_init(self):
 
168
        MockMethod.bind(self, CommitDialogNoWidgets, 'setup_params')
 
169
        MockMethod.bind(self, CommitDialogNoWidgets, 'construct')
 
170
        MockMethod.bind(self, CommitDialogNoWidgets, 'fill_in_data')
 
171
 
 
172
        tree = self.make_branch_and_tree('tree')
 
173
        rev_id = tree.commit('first')
 
174
        dlg = CommitDialogNoWidgets(tree)
 
175
        self.assertIs(tree, dlg._wt)
 
176
        self.assertIs(None, dlg._selected)
 
177
        self.assertTrue(dlg._enable_per_file_commits)
 
178
        self.assertTrue(dlg._commit_all_changes)
 
179
        self.assertIs(None, dlg.committed_revision_id)
 
180
        self.assertIs(None, dlg._last_selected_file)
 
181
        self.assertIsInstance(
 
182
            dlg._saved_commit_messages_manager, SavedCommitMessagesManager)
 
183
        self.assertTrue(CommitDialogNoWidgets.setup_params.called)
 
184
        self.assertTrue(CommitDialogNoWidgets.construct.called)
 
185
        self.assertTrue(CommitDialogNoWidgets.fill_in_data.called)
 
186
 
147
187
    def test_setup_parameters_no_pending(self):
148
188
        tree = self.make_branch_and_tree('tree')
149
189
        rev_id = tree.commit('first')