~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf_ui.py

  • Committer: Aaron Bentley
  • Date: 2008-10-27 18:52:59 UTC
  • mto: This revision was merged to the branch mainline in revision 3823.
  • Revision ID: aaron@aaronbentley.com-20081027185259-egeejr8bbaug4b2q
Test kind, add, binary, --all

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
class ExpectShelver(shelf_ui.Shelver):
25
25
    """A variant of Shelver that intercepts console activity, for testing."""
26
26
 
27
 
    def __init__(self, tree, target_tree):
28
 
        shelf_ui.Shelver.__init__(self, tree, target_tree, None)
 
27
    def __init__(self, work_tree, target_tree, path=None, auto=False,
 
28
                 auto_apply=False, file_list=None, message=None):
 
29
        shelf_ui.Shelver.__init__(self, work_tree, target_tree, path,
 
30
                                  auto, auto_apply, file_list, message)
29
31
        self.expected = []
30
32
        self.diff_writer = StringIO()
31
33
 
110
112
        shelver.run()
111
113
        self.assertFileEqual(LINES_AY, 'tree/foo')
112
114
 
 
115
    def test_shelve_binary_change(self):
 
116
        tree = self.create_shelvable_tree()
 
117
        self.build_tree_contents([('tree/foo', '\x00')])
 
118
        shelver = ExpectShelver(tree, tree.basis_tree())
 
119
        shelver.expect('Shelve binary changes? [yNfq]', 'y')
 
120
        shelver.expect('Shelve 1 change(s)? [yNfq]', 'y')
 
121
        shelver.run()
 
122
        self.assertFileEqual(LINES_AJ, 'tree/foo')
 
123
 
 
124
 
113
125
    def test_shelve_rename(self):
114
126
        tree = self.create_shelvable_tree()
115
127
        tree.revert()
129
141
        shelver.run()
130
142
        self.assertFileEqual(LINES_AJ, 'tree/foo')
131
143
 
 
144
    def test_shelve_creation(self):
 
145
        tree = self.make_branch_and_tree('tree')
 
146
        tree.commit('add tree root')
 
147
        self.build_tree(['tree/foo'])
 
148
        tree.add('foo')
 
149
        shelver = ExpectShelver(tree, tree.basis_tree())
 
150
        shelver.expect('Shelve adding file "foo"? [yNfq]', 'y')
 
151
        shelver.expect('Shelve 1 change(s)? [yNfq]', 'y')
 
152
        shelver.run()
 
153
        self.failIfExists('tree/foo')
 
154
 
 
155
    def test_shelve_kind_change(self):
 
156
        tree = self.create_shelvable_tree()
 
157
        os.unlink('tree/foo')
 
158
        os.mkdir('tree/foo')
 
159
        shelver = ExpectShelver(tree, tree.basis_tree())
 
160
        shelver.expect('Shelve changing "foo" from file to directory? [yNfq]',
 
161
                       'y')
 
162
        shelver.expect('Shelve 1 change(s)? [yNfq]', 'y')
 
163
 
132
164
    def test_shelve_finish(self):
133
165
        tree = self.create_shelvable_tree()
134
166
        shelver = ExpectShelver(tree, tree.basis_tree())
143
175
        shelver.expect('Shelve? [yNfq]', 'q')
144
176
        self.assertRaises(SystemExit, shelver.run)
145
177
        self.assertFileEqual(LINES_ZY, 'tree/foo')
 
178
 
 
179
    def test_shelve_all(self):
 
180
        tree = self.create_shelvable_tree()
 
181
        ExpectShelver.from_args(all=True, dir='tree').run()
 
182
        self.assertFileEqual(LINES_AJ, 'tree/foo')