~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf_ui.py

  • Committer: Vincent Ladeuil
  • Date: 2009-05-05 15:31:34 UTC
  • mto: (4343.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4344.
  • Revision ID: v.ladeuil+lp@free.fr-20090505153134-q4bp4is9gywsmzrv
Clean up test for log formats.

* bzrlib/tests/blackbox/test_logformats.py:
Update tests to actual style.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
    def __init__(self, work_tree, target_tree, diff_writer=None,
29
29
                 auto=False, auto_apply=False, file_list=None, message=None,
30
 
                 destroy=False, reporter=None):
 
30
                 destroy=False):
31
31
        shelf_ui.Shelver.__init__(self, work_tree, target_tree, diff_writer,
32
32
                                  auto, auto_apply, file_list, message,
33
 
                                  destroy, reporter=reporter)
 
33
                                  destroy)
34
34
        self.expected = []
35
35
        self.diff_writer = StringIO()
36
36
 
165
165
        shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
166
166
 
167
167
    def test_shelve_modify_target(self):
168
 
        self.requireFeature(tests.SymlinkFeature)
169
168
        tree = self.create_shelvable_tree()
170
169
        os.symlink('bar', 'tree/baz')
171
170
        tree.add('baz', 'baz-id')
225
224
        self.assertFileEqual(LINES_AJ, 'tree/foo')
226
225
 
227
226
 
228
 
class TestApplyReporter(TestShelver):
229
 
 
230
 
    def test_shelve_not_diff(self):
231
 
        tree = self.create_shelvable_tree()
232
 
        shelver = ExpectShelver(tree, tree.basis_tree(),
233
 
                                reporter=shelf_ui.ApplyReporter())
234
 
        shelver.expect('Apply change? [yNfq?]', 'n')
235
 
        shelver.expect('Apply change? [yNfq?]', 'n')
236
 
        # No final shelving prompt because no changes were selected
237
 
        shelver.run()
238
 
        self.assertFileEqual(LINES_ZY, 'tree/foo')
239
 
 
240
 
    def test_shelve_diff_no(self):
241
 
        tree = self.create_shelvable_tree()
242
 
        shelver = ExpectShelver(tree, tree.basis_tree(),
243
 
                                reporter=shelf_ui.ApplyReporter())
244
 
        shelver.expect('Apply change? [yNfq?]', 'y')
245
 
        shelver.expect('Apply change? [yNfq?]', 'y')
246
 
        shelver.expect('Apply 2 change(s)? [yNfq?]', 'n')
247
 
        shelver.run()
248
 
        self.assertFileEqual(LINES_ZY, 'tree/foo')
249
 
 
250
 
    def test_shelve_diff(self):
251
 
        tree = self.create_shelvable_tree()
252
 
        shelver = ExpectShelver(tree, tree.basis_tree(),
253
 
                                reporter=shelf_ui.ApplyReporter())
254
 
        shelver.expect('Apply change? [yNfq?]', 'y')
255
 
        shelver.expect('Apply change? [yNfq?]', 'y')
256
 
        shelver.expect('Apply 2 change(s)? [yNfq?]', 'y')
257
 
        shelver.run()
258
 
        self.assertFileEqual(LINES_AJ, 'tree/foo')
259
 
 
260
 
    def test_shelve_binary_change(self):
261
 
        tree = self.create_shelvable_tree()
262
 
        self.build_tree_contents([('tree/foo', '\x00')])
263
 
        shelver = ExpectShelver(tree, tree.basis_tree(),
264
 
                                reporter=shelf_ui.ApplyReporter())
265
 
        shelver.expect('Apply binary changes? [yNfq?]', 'y')
266
 
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
267
 
        shelver.run()
268
 
        self.assertFileEqual(LINES_AJ, 'tree/foo')
269
 
 
270
 
    def test_shelve_rename(self):
271
 
        tree = self.create_shelvable_tree()
272
 
        tree.rename_one('foo', 'bar')
273
 
        shelver = ExpectShelver(tree, tree.basis_tree(),
274
 
                                reporter=shelf_ui.ApplyReporter())
275
 
        shelver.expect('Rename "bar" => "foo"? [yNfq?]', 'y')
276
 
        shelver.expect('Apply change? [yNfq?]', 'y')
277
 
        shelver.expect('Apply change? [yNfq?]', 'y')
278
 
        shelver.expect('Apply 3 change(s)? [yNfq?]', 'y')
279
 
        shelver.run()
280
 
        self.assertFileEqual(LINES_AJ, 'tree/foo')
281
 
 
282
 
    def test_shelve_deletion(self):
283
 
        tree = self.create_shelvable_tree()
284
 
        os.unlink('tree/foo')
285
 
        shelver = ExpectShelver(tree, tree.basis_tree(),
286
 
                                reporter=shelf_ui.ApplyReporter())
287
 
        shelver.expect('Add file "foo"? [yNfq?]', 'y')
288
 
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
289
 
        shelver.run()
290
 
        self.assertFileEqual(LINES_AJ, 'tree/foo')
291
 
 
292
 
    def test_shelve_creation(self):
293
 
        tree = self.make_branch_and_tree('tree')
294
 
        tree.commit('add tree root')
295
 
        self.build_tree(['tree/foo'])
296
 
        tree.add('foo')
297
 
        shelver = ExpectShelver(tree, tree.basis_tree(),
298
 
                                reporter=shelf_ui.ApplyReporter())
299
 
        shelver.expect('Delete file "foo"? [yNfq?]', 'y')
300
 
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
301
 
        shelver.run()
302
 
        self.failIfExists('tree/foo')
303
 
 
304
 
    def test_shelve_kind_change(self):
305
 
        tree = self.create_shelvable_tree()
306
 
        os.unlink('tree/foo')
307
 
        os.mkdir('tree/foo')
308
 
        shelver = ExpectShelver(tree, tree.basis_tree(),
309
 
                               reporter=shelf_ui.ApplyReporter())
310
 
        shelver.expect('Change "foo" from directory to a file? [yNfq?]', 'y')
311
 
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
312
 
 
313
 
    def test_shelve_modify_target(self):
314
 
        self.requireFeature(tests.SymlinkFeature)
315
 
        tree = self.create_shelvable_tree()
316
 
        os.symlink('bar', 'tree/baz')
317
 
        tree.add('baz', 'baz-id')
318
 
        tree.commit("Add symlink")
319
 
        os.unlink('tree/baz')
320
 
        os.symlink('vax', 'tree/baz')
321
 
        shelver = ExpectShelver(tree, tree.basis_tree(),
322
 
                                reporter=shelf_ui.ApplyReporter())
323
 
        shelver.expect('Change target of "baz" from "vax" to "bar"? [yNfq?]',
324
 
                       'y')
325
 
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
326
 
        shelver.run()
327
 
        self.assertEqual('bar', os.readlink('tree/baz'))
328
 
 
329
 
 
330
227
class TestUnshelver(tests.TestCaseWithTransport):
331
228
 
332
229
    def create_tree_with_shelf(self):