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

  • Committer: Aaron Bentley
  • Date: 2008-05-10 03:23:00 UTC
  • mto: This revision was merged to the branch mainline in revision 492.
  • Revision ID: aaron@aaronbentley.com-20080510032300-v7mdhm2zae04o356
Add more merge tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
class MockWindow(object):
102
102
    def __init__(self):
103
103
        self.diff = MockDiffWidget()
 
104
        self.merge_successful = False
104
105
 
105
106
    def set_title(self, title):
106
107
        self.title = title
117
118
    def _merge_successful(self):
118
119
        self.merge_successful = True
119
120
 
 
121
    def _conflicts(self):
 
122
        self.conflicts = True
 
123
 
120
124
 
121
125
class TestDiffController(tests.TestCaseWithTransport):
122
126
 
153
157
 
154
158
class TestMergeDirectiveController(tests.TestCaseWithTransport):
155
159
 
156
 
    def test_perform_merge(self):
 
160
    def make_this_other_directive(self):
157
161
        this = self.make_branch_and_tree('this')
158
162
        this.commit('first commit')
159
163
        other = this.bzrdir.sprout('other').open_workingtree()
160
 
        self.build_tree_contents([('foo', 'bar')])
 
164
        self.build_tree_contents([('other/foo', 'bar')])
 
165
        other.add('foo')
161
166
        other.commit('second commit')
162
167
        other.lock_write()
163
168
        try:
166
171
                                                    0, 'this')
167
172
        finally:
168
173
            other.unlock()
 
174
        return this, other, directive
 
175
 
 
176
    def make_merged_window(self, directive):
169
177
        window = MockWindow()
170
178
        controller = MergeDirectiveController('directive', directive, window)
171
179
        controller.perform_merge(window)
 
180
        return window
 
181
 
 
182
    def test_perform_merge_success(self):
 
183
        this, other, directive = self.make_this_other_directive()
 
184
        window = self.make_merged_window(directive)
172
185
        self.assertTrue(window.merge_successful)
173
186
        self.assertEqual(other.last_revision(), this.get_parent_ids()[1])
174
 
        self.assertFileEqual('bar', 'foo')
 
187
        self.assertFileEqual('bar', 'this/foo')
 
188
 
 
189
    def test_perform_merge_conflicts(self):
 
190
        this, other, directive = self.make_this_other_directive()
 
191
        self.build_tree_contents([('this/foo', 'bar')])
 
192
        this.add('foo')
 
193
        this.commit('message')
 
194
        window = self.make_merged_window(directive)
 
195
        self.assertFalse(window.merge_successful)
 
196
        self.assertTrue(window.conflicts)
 
197
        self.assertEqual(other.last_revision(), this.get_parent_ids()[1])
 
198
        self.assertFileEqual('bar', 'this/foo')
175
199
 
176
200
 
177
201
class Test_IterChangesToStatus(tests.TestCaseWithTransport):