/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_generic_processor.py

  • Committer: Ian Clatworthy
  • Date: 2009-02-20 02:34:38 UTC
  • mto: (0.64.124 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090220023438-b1ckd4w2t2iw7if2
file/symlink <-> directory change tests & fix

Show diffs side-by-side

added added

removed removed

Lines of Context:
290
290
        self.assertExecutable(branch, revtree2, path, False)
291
291
 
292
292
 
 
293
class TestModifyTricky(TestCaseForGenericProcessor):
 
294
 
 
295
    def file_command_iter(self, path1, path2, kind='file'):
 
296
        # Revno 1: create a file or symlink in a directory
 
297
        # Revno 2: create a second file that implicitly deletes the
 
298
        # first one because either:
 
299
        # * the new file is a in directory with the old file name
 
300
        # * the new file has the same name as the directory of the first
 
301
        def command_list():
 
302
            author = ['', 'bugs@a.com', time.time(), time.timezone]
 
303
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
 
304
            def files_one():
 
305
                yield commands.FileModifyCommand(path1, kind, False,
 
306
                        None, "aaa")
 
307
            yield commands.CommitCommand('head', '1', author,
 
308
                committer, "commit 1", None, [], files_one)
 
309
            def files_two():
 
310
                yield commands.FileModifyCommand(path2, kind, False,
 
311
                        None, "bbb")
 
312
            yield commands.CommitCommand('head', '2', author,
 
313
                committer, "commit 2", ":1", [], files_two)
 
314
        return command_list
 
315
 
 
316
 
 
317
    def test_modify_file_becomes_directory(self):
 
318
        handler, branch = self.get_handler()
 
319
        path1 = 'a/b'
 
320
        path2 = 'a/b/c'
 
321
        handler.process(self.file_command_iter(path1, path2))
 
322
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
323
            expected_added=[('a',), (path1,)])
 
324
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
325
            expected_added=[(path2,)],
 
326
            expected_kind_changed=[(path1, 'file', 'directory')])
 
327
        self.assertContent(branch, revtree1, path1, "aaa")
 
328
        self.assertContent(branch, revtree2, path2, "bbb")
 
329
 
 
330
    def test_modify_directory_becomes_file(self):
 
331
        handler, branch = self.get_handler()
 
332
        path1 = 'a/b/c'
 
333
        path2 = 'a/b'
 
334
        handler.process(self.file_command_iter(path1, path2))
 
335
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
336
            expected_added=[('a',), ('a/b',), (path1,)])
 
337
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
338
            expected_removed=[(path1,),],
 
339
            expected_kind_changed=[(path2, 'directory', 'file')])
 
340
        self.assertContent(branch, revtree1, path1, "aaa")
 
341
        self.assertContent(branch, revtree2, path2, "bbb")
 
342
 
 
343
    def test_modify_symlink_becomes_directory(self):
 
344
        handler, branch = self.get_handler()
 
345
        path1 = 'a/b'
 
346
        path2 = 'a/b/c'
 
347
        handler.process(self.file_command_iter(path1, path2, 'symlink'))
 
348
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
349
            expected_added=[('a',), (path1,)])
 
350
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
351
            expected_added=[(path2,)],
 
352
            expected_kind_changed=[(path1, 'symlink', 'directory')])
 
353
        self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
 
354
        self.assertSymlinkTarget(branch, revtree2, path2, "bbb")
 
355
 
 
356
    def test_modify_directory_becomes_symlink(self):
 
357
        handler, branch = self.get_handler()
 
358
        path1 = 'a/b/c'
 
359
        path2 = 'a/b'
 
360
        handler.process(self.file_command_iter(path1, path2, 'symlink'))
 
361
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
362
            expected_added=[('a',), ('a/b',), (path1,)])
 
363
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
364
            expected_removed=[(path1,),],
 
365
            expected_kind_changed=[(path2, 'directory', 'symlink')])
 
366
        self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
 
367
        self.assertSymlinkTarget(branch, revtree2, path2, "bbb")
 
368
 
 
369
 
293
370
class TestDelete(TestCaseForGenericProcessor):
294
371
 
295
372
    def file_command_iter(self, path, kind='file'):