/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: Jelmer Vernooij
  • Date: 2008-06-29 16:20:15 UTC
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629162015-amhe7xj4cdmup4id
Rename GtkProgressBarStack to GtkWindowProgressBarStack

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from cStringIO import StringIO
19
19
import os
20
20
 
21
 
from bzrlib import (
22
 
    conflicts,
23
 
    errors,
24
 
    tests,
25
 
    )
26
 
try:
27
 
    from bzrlib.tests.features import UnicodeFilenameFeature
28
 
except ImportError: # bzr < 2.5
29
 
    from bzrlib.tests import UnicodeFilenameFeature
 
21
from bzrlib import errors, tests
30
22
from bzrlib.merge_directive import MergeDirective2
31
23
 
32
24
from bzrlib.plugins.gtk.diff import (
33
25
    DiffController,
34
26
    DiffView,
35
 
    DiffWidget,
36
27
    iter_changes_to_status,
37
28
    MergeDirectiveController,
38
29
    )
39
 
from bzrlib.plugins.gtk.tests import MockMethod
40
 
 
41
 
 
42
30
eg_diff = """\
43
31
=== modified file 'tests/test_diff.py'
44
32
--- tests/test_diff.py  2008-03-11 13:18:28 +0000
81
69
class TestDiffView(tests.TestCaseWithTransport):
82
70
 
83
71
    def test_unicode(self):
84
 
        self.requireFeature(UnicodeFilenameFeature)
 
72
        self.requireFeature(tests.UnicodeFilenameFeature)
85
73
 
86
74
        tree = self.make_branch_and_tree('tree')
87
75
        self.build_tree([u'tree/\u03a9'])
92
80
        view.show_diff(None)
93
81
        buf = view.buffer
94
82
        start, end = buf.get_bounds()
95
 
        text = buf.get_text(start, end, True)
 
83
        text = buf.get_text(start, end)
96
84
        self.assertContainsRe(text,
97
85
            "=== added file '\xce\xa9'\n"
98
86
            '--- .*\t1970-01-01 00:00:00 \\+0000\n'
103
91
            )
104
92
 
105
93
 
106
 
 
107
 
class FakeDiffWidget(DiffWidget):
108
 
 
109
 
    SHOW_WIDGETS = False
110
 
 
111
 
 
112
 
class TestDiffWidget(tests.TestCaseWithTransport):
113
 
 
114
 
    def test_treeview_cursor_cbd_with_destroyed_treeview(self):
115
 
        widget = FakeDiffWidget()
116
 
        widget.set_diff_text_sections([('a', None, 'patch')])
117
 
        MockMethod.bind(self, widget.diff_view, 'show_diff')
118
 
        widget.treeview.destroy()
119
 
        widget._treeview_cursor_cb(None)
120
 
        self.assertFalse(widget.diff_view.show_diff.called)
121
 
 
122
 
 
123
94
class MockDiffWidget(object):
124
95
 
125
96
    def set_diff_text_sections(self, sections):
127
98
 
128
99
 
129
100
class MockWindow(object):
130
 
 
131
101
    def __init__(self):
132
102
        self.diff = MockDiffWidget()
133
103
        self.merge_successful = False
333
303
            [('a-id', 'a', 'removed', 'a'),
334
304
             ('b-id', 'b', 'removed', 'b/'),
335
305
            ], tree)
336
 
 
337
 
    def test_status_missing_file(self):
338
 
        this = self.make_branch_and_tree('this')
339
 
        self.build_tree(['this/foo'])
340
 
        this.add(['foo'], ['foo-id'])
341
 
        this.commit('add')
342
 
 
343
 
        other = this.bzrdir.sprout('other').open_workingtree()
344
 
 
345
 
        os.remove('this/foo')
346
 
        this.remove('foo', force=True)
347
 
        this.commit('remove')
348
 
 
349
 
        f = open('other/foo', 'wt')
350
 
        try:
351
 
            f.write('Modified\n')
352
 
        finally:
353
 
            f.close()
354
 
        other.commit('modified')
355
 
 
356
 
        this.merge_from_branch(other.branch)
357
 
        conflicts.resolve(this)
358
 
 
359
 
        self.assertStatusEqual(
360
 
            [('foo-id', 'foo.OTHER', 'missing', 'foo.OTHER'),],
361
 
            this)
362
 
 
363
 
    def test_status_missing_directory(self):
364
 
        this = self.make_branch_and_tree('this')
365
 
        self.build_tree(['this/foo/', 'this/foo/bar'])
366
 
        this.add(['foo', 'foo/bar'], ['foo-id', 'bar-id'])
367
 
        this.commit('add')
368
 
 
369
 
        other = this.bzrdir.sprout('other').open_workingtree()
370
 
 
371
 
        os.remove('this/foo/bar')
372
 
        os.rmdir('this/foo')
373
 
        this.remove('foo', force=True)
374
 
        this.commit('remove')
375
 
 
376
 
        f = open('other/foo/bar', 'wt')
377
 
        try:
378
 
            f.write('Modified\n')
379
 
        finally:
380
 
            f.close()
381
 
        other.commit('modified')
382
 
 
383
 
        this.merge_from_branch(other.branch)
384
 
        conflicts.resolve(this)
385
 
 
386
 
        self.assertStatusEqual(
387
 
            [('foo-id', u'foo', 'added', u'foo/'),
388
 
             ('bar-id', u'foo/bar.OTHER', 'missing', u'foo/bar.OTHER'),],
389
 
            this)