/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 03:24:15 UTC
  • mto: (0.64.124 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090220032415-xyrq8o11ofihfuh8
file/symlink <-> directory rename tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
472
472
            expected_added=[('b',)])
473
473
 
474
474
 
 
475
class TestRenameTricky(TestCaseForGenericProcessor):
 
476
 
 
477
    def file_command_iter(self, path1, old_path2, new_path2, kind='file'):
 
478
        # Revno 1: create two files or symlinks in a directory
 
479
        # Revno 2: rename the second file so that it implicitly deletes the
 
480
        # first one because either:
 
481
        # * the new file is a in directory with the old file name
 
482
        # * the new file has the same name as the directory of the first
 
483
        def command_list():
 
484
            author = ['', 'bugs@a.com', time.time(), time.timezone]
 
485
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
 
486
            def files_one():
 
487
                yield commands.FileModifyCommand(path1, kind, False,
 
488
                        None, "aaa")
 
489
                yield commands.FileModifyCommand(old_path2, kind, False,
 
490
                        None, "bbb")
 
491
            yield commands.CommitCommand('head', '1', author,
 
492
                committer, "commit 1", None, [], files_one)
 
493
            def files_two():
 
494
                yield commands.FileRenameCommand(old_path2, new_path2)
 
495
            yield commands.CommitCommand('head', '2', author,
 
496
                committer, "commit 2", ":1", [], files_two)
 
497
        return command_list
 
498
 
 
499
 
 
500
    def test_rename_file_becomes_directory(self):
 
501
        handler, branch = self.get_handler()
 
502
        old_path2 = 'foo'
 
503
        path1     = 'a/b'
 
504
        new_path2 = 'a/b/c'
 
505
        handler.process(self.file_command_iter(path1, old_path2, new_path2))
 
506
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
507
            expected_added=[('a',), (path1,), (old_path2,)])
 
508
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
509
            expected_renamed=[(old_path2, new_path2)],
 
510
            expected_kind_changed=[(path1, 'file', 'directory')])
 
511
        self.assertContent(branch, revtree1, path1, "aaa")
 
512
        self.assertContent(branch, revtree2, new_path2, "bbb")
 
513
 
 
514
    def test_rename_directory_becomes_file(self):
 
515
        handler, branch = self.get_handler()
 
516
        old_path2 = 'foo'
 
517
        path1     = 'a/b/c'
 
518
        new_path2 = 'a/b'
 
519
        handler.process(self.file_command_iter(path1, old_path2, new_path2))
 
520
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
521
            expected_added=[('a',), ('a/b',), (path1,), (old_path2,)])
 
522
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
523
            expected_renamed=[(old_path2, new_path2)],
 
524
            expected_removed=[(path1,), (new_path2,)])
 
525
        self.assertContent(branch, revtree1, path1, "aaa")
 
526
        self.assertContent(branch, revtree2, new_path2, "bbb")
 
527
 
 
528
    def test_rename_symlink_becomes_directory(self):
 
529
        handler, branch = self.get_handler()
 
530
        old_path2 = 'foo'
 
531
        path1     = 'a/b'
 
532
        new_path2 = 'a/b/c'
 
533
        handler.process(self.file_command_iter(path1, old_path2, new_path2,
 
534
            'symlink'))
 
535
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
536
            expected_added=[('a',), (path1,), (old_path2,)])
 
537
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
538
            expected_renamed=[(old_path2, new_path2)],
 
539
            expected_kind_changed=[(path1, 'symlink', 'directory')])
 
540
        self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
 
541
        self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb")
 
542
 
 
543
    def test_rename_directory_becomes_symlink(self):
 
544
        handler, branch = self.get_handler()
 
545
        old_path2 = 'foo'
 
546
        path1     = 'a/b/c'
 
547
        new_path2 = 'a/b'
 
548
        handler.process(self.file_command_iter(path1, old_path2, new_path2,
 
549
            'symlink'))
 
550
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
551
            expected_added=[('a',), ('a/b',), (path1,), (old_path2,)])
 
552
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
553
            expected_renamed=[(old_path2, new_path2)],
 
554
            expected_removed=[(path1,), (new_path2,)])
 
555
        self.assertSymlinkTarget(branch, revtree1, path1, "aaa")
 
556
        self.assertSymlinkTarget(branch, revtree2, new_path2, "bbb")
 
557
 
 
558
 
475
559
class TestCopy(TestCaseForGenericProcessor):
476
560
 
477
561
    def file_command_iter(self, src_path, dest_path, kind='file'):