/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-08-24 01:27:22 UTC
  • mto: (0.64.225 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090824012722-bx5pzeuh2gkeo5d2
add tests for symlink renaming

Show diffs side-by-side

added added

removed removed

Lines of Context:
641
641
 
642
642
class TestImportToPackRename(TestCaseForGenericProcessor):
643
643
 
644
 
    def get_command_iter(self, old_path, new_path):
 
644
    def get_command_iter(self, old_path, new_path, kind='file'):
645
645
        # Revno 1: create a file or symlink
646
646
        # Revno 2: rename it
647
647
        def command_list():
648
648
            author = ['', 'bugs@a.com', time.time(), time.timezone]
649
649
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
650
650
            def files_one():
651
 
                yield commands.FileModifyCommand(old_path, 'file', False,
 
651
                yield commands.FileModifyCommand(old_path, kind, False,
652
652
                        None, "aaa")
653
653
            yield commands.CommitCommand('head', '1', author,
654
654
                committer, "commit 1", None, [], files_one)
658
658
                committer, "commit 2", ":1", [], files_two)
659
659
        return command_list
660
660
 
661
 
    def test_rename_in_root(self):
662
 
        handler, branch = self.get_handler()
663
 
        old_path = 'a'
664
 
        new_path = 'b'
665
 
        handler.process(self.get_command_iter(old_path, new_path))
666
 
        revtree1, revtree2 = self.assertChanges(branch, 2,
667
 
            expected_renamed=[(old_path, new_path)])
668
 
        self.assertRevisionRoot(revtree1, old_path)
669
 
        self.assertRevisionRoot(revtree2, new_path)
670
 
 
671
 
    def test_rename_in_subdir(self):
672
 
        handler, branch = self.get_handler()
673
 
        old_path = 'a/a'
674
 
        new_path = 'a/b'
675
 
        handler.process(self.get_command_iter(old_path, new_path))
676
 
        self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
677
 
 
678
 
    def test_rename_to_new_dir(self):
679
 
        handler, branch = self.get_handler()
680
 
        old_path = 'a/a'
681
 
        new_path = 'b/a'
682
 
        handler.process(self.get_command_iter(old_path, new_path))
 
661
    def test_rename_file_in_root(self):
 
662
        handler, branch = self.get_handler()
 
663
        old_path = 'a'
 
664
        new_path = 'b'
 
665
        handler.process(self.get_command_iter(old_path, new_path))
 
666
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
667
            expected_renamed=[(old_path, new_path)])
 
668
        self.assertRevisionRoot(revtree1, old_path)
 
669
        self.assertRevisionRoot(revtree2, new_path)
 
670
 
 
671
    def test_rename_symlink_in_root(self):
 
672
        handler, branch = self.get_handler()
 
673
        old_path = 'a'
 
674
        new_path = 'b'
 
675
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
 
676
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
677
            expected_renamed=[(old_path, new_path)])
 
678
        self.assertRevisionRoot(revtree1, old_path)
 
679
        self.assertRevisionRoot(revtree2, new_path)
 
680
 
 
681
    def test_rename_file_in_subdir(self):
 
682
        handler, branch = self.get_handler()
 
683
        old_path = 'a/a'
 
684
        new_path = 'a/b'
 
685
        handler.process(self.get_command_iter(old_path, new_path))
 
686
        self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
 
687
 
 
688
    def test_rename_symlink_in_subdir(self):
 
689
        handler, branch = self.get_handler()
 
690
        old_path = 'a/a'
 
691
        new_path = 'a/b'
 
692
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
 
693
        self.assertChanges(branch, 2, expected_renamed=[(old_path, new_path)])
 
694
 
 
695
    def test_rename_file_to_new_dir(self):
 
696
        handler, branch = self.get_handler()
 
697
        old_path = 'a/a'
 
698
        new_path = 'b/a'
 
699
        handler.process(self.get_command_iter(old_path, new_path))
 
700
        self.assertChanges(branch, 2,
 
701
            expected_renamed=[(old_path, new_path)],
 
702
            expected_added=[('b',)],
 
703
            expected_removed=[('a',)])
 
704
 
 
705
    def test_rename_symlink_to_new_dir(self):
 
706
        handler, branch = self.get_handler()
 
707
        old_path = 'a/a'
 
708
        new_path = 'b/a'
 
709
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
683
710
        self.assertChanges(branch, 2,
684
711
            expected_renamed=[(old_path, new_path)],
685
712
            expected_added=[('b',)],
689
716
class TestImportToPackRenameNew(TestCaseForGenericProcessor):
690
717
    """Test rename of a newly added file."""
691
718
 
692
 
    def get_command_iter(self, old_path, new_path):
 
719
    def get_command_iter(self, old_path, new_path, kind='file'):
693
720
        # Revno 1: create a file and rename it
694
721
        def command_list():
695
722
            author = ['', 'bugs@a.com', time.time(), time.timezone]
696
723
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
697
724
            def files_one():
698
 
                yield commands.FileModifyCommand(old_path, 'file', False,
 
725
                yield commands.FileModifyCommand(old_path, kind, False,
699
726
                        None, "aaa")
700
727
                yield commands.FileRenameCommand(old_path, new_path)
701
728
            yield commands.CommitCommand('head', '1', author,
702
729
                committer, "commit 1", None, [], files_one)
703
730
        return command_list
704
731
 
705
 
    def test_rename_new_in_root(self):
706
 
        handler, branch = self.get_handler()
707
 
        old_path = 'a'
708
 
        new_path = 'b'
709
 
        handler.process(self.get_command_iter(old_path, new_path))
710
 
        revtree0, revtree1 = self.assertChanges(branch, 1,
711
 
            expected_added=[(new_path,)])
712
 
        self.assertRevisionRoot(revtree1, new_path)
713
 
 
714
 
    def test_rename_new_in_subdir(self):
715
 
        handler, branch = self.get_handler()
716
 
        old_path = 'a/a'
717
 
        new_path = 'a/b'
718
 
        handler.process(self.get_command_iter(old_path, new_path))
 
732
    def test_rename_new_file_in_root(self):
 
733
        handler, branch = self.get_handler()
 
734
        old_path = 'a'
 
735
        new_path = 'b'
 
736
        handler.process(self.get_command_iter(old_path, new_path))
 
737
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
738
            expected_added=[(new_path,)])
 
739
        self.assertRevisionRoot(revtree1, new_path)
 
740
 
 
741
    def test_rename_new_symlink_in_root(self):
 
742
        handler, branch = self.get_handler()
 
743
        old_path = 'a'
 
744
        new_path = 'b'
 
745
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
 
746
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
747
            expected_added=[(new_path,)])
 
748
        self.assertRevisionRoot(revtree1, new_path)
 
749
 
 
750
    def test_rename_new_file_in_subdir(self):
 
751
        handler, branch = self.get_handler()
 
752
        old_path = 'a/a'
 
753
        new_path = 'a/b'
 
754
        handler.process(self.get_command_iter(old_path, new_path))
 
755
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
756
            expected_added=[('a',), (new_path,)])
 
757
 
 
758
    def test_rename_new_symlink_in_subdir(self):
 
759
        handler, branch = self.get_handler()
 
760
        old_path = 'a/a'
 
761
        new_path = 'a/b'
 
762
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
719
763
        revtree0, revtree1 = self.assertChanges(branch, 1,
720
764
            expected_added=[('a',), (new_path,)])
721
765
 
723
767
class TestImportToPackRenameToDeleted(TestCaseForGenericProcessor):
724
768
    """Test rename to a destination path deleted in this commit."""
725
769
 
726
 
    def get_command_iter(self, old_path, new_path):
 
770
    def get_command_iter(self, old_path, new_path, kind='file'):
727
771
        # Revno 1: create two files
728
772
        # Revno 2: delete one, rename the other one to that path
729
773
        def command_list():
730
774
            author = ['', 'bugs@a.com', time.time(), time.timezone]
731
775
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
732
776
            def files_one():
733
 
                yield commands.FileModifyCommand(old_path, 'file', False,
 
777
                yield commands.FileModifyCommand(old_path, kind, False,
734
778
                        None, "aaa")
735
 
                yield commands.FileModifyCommand(new_path, 'file', False,
 
779
                yield commands.FileModifyCommand(new_path, kind, False,
736
780
                        None, "bbb")
737
781
            yield commands.CommitCommand('head', '1', author,
738
782
                committer, "commit 1", None, [], files_one)
743
787
                committer, "commit 2", ":1", [], files_two)
744
788
        return command_list
745
789
 
746
 
    def test_rename_to_deleted_in_root(self):
747
 
        handler, branch = self.get_handler()
748
 
        old_path = 'a'
749
 
        new_path = 'b'
750
 
        handler.process(self.get_command_iter(old_path, new_path))
751
 
        revtree0, revtree1 = self.assertChanges(branch, 1,
752
 
            expected_added=[(old_path,), (new_path,)])
753
 
        revtree1, revtree2 = self.assertChanges(branch, 2,
754
 
            expected_removed=[(new_path,)],
755
 
            expected_renamed=[(old_path, new_path)])
756
 
        self.assertContent(branch, revtree1, old_path, "aaa")
757
 
        self.assertContent(branch, revtree1, new_path, "bbb")
758
 
        self.assertContent(branch, revtree2, new_path, "aaa")
759
 
        self.assertRevisionRoot(revtree1, old_path)
760
 
        self.assertRevisionRoot(revtree1, new_path)
761
 
 
762
 
    def test_rename_to_deleted_in_subdir(self):
763
 
        handler, branch = self.get_handler()
764
 
        old_path = 'd/a'
765
 
        new_path = 'd/b'
766
 
        handler.process(self.get_command_iter(old_path, new_path))
767
 
        revtree0, revtree1 = self.assertChanges(branch, 1,
768
 
            expected_added=[('d',), (old_path,), (new_path,)])
769
 
        revtree1, revtree2 = self.assertChanges(branch, 2,
770
 
            expected_removed=[(new_path,)],
771
 
            expected_renamed=[(old_path, new_path)])
772
 
        self.assertContent(branch, revtree1, old_path, "aaa")
773
 
        self.assertContent(branch, revtree1, new_path, "bbb")
774
 
        self.assertContent(branch, revtree2, new_path, "aaa")
775
 
 
776
 
    def test_rename_to_deleted_new_dir(self):
777
 
        handler, branch = self.get_handler()
778
 
        old_path = 'd1/a'
779
 
        new_path = 'd2/b'
780
 
        handler.process(self.get_command_iter(old_path, new_path))
781
 
        revtree0, revtree1 = self.assertChanges(branch, 1,
782
 
            expected_added=[('d1',), (old_path,), ('d2',), (new_path,)])
783
 
        revtree1, revtree2 = self.assertChanges(branch, 2,
784
 
            expected_removed=[('d1',), (new_path,)],
785
 
            expected_renamed=[(old_path, new_path)])
786
 
        self.assertContent(branch, revtree1, old_path, "aaa")
787
 
        self.assertContent(branch, revtree1, new_path, "bbb")
788
 
        self.assertContent(branch, revtree2, new_path, "aaa")
 
790
    def test_rename_to_deleted_file_in_root(self):
 
791
        handler, branch = self.get_handler()
 
792
        old_path = 'a'
 
793
        new_path = 'b'
 
794
        handler.process(self.get_command_iter(old_path, new_path))
 
795
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
796
            expected_added=[(old_path,), (new_path,)])
 
797
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
798
            expected_removed=[(new_path,)],
 
799
            expected_renamed=[(old_path, new_path)])
 
800
        self.assertContent(branch, revtree1, old_path, "aaa")
 
801
        self.assertContent(branch, revtree1, new_path, "bbb")
 
802
        self.assertContent(branch, revtree2, new_path, "aaa")
 
803
        self.assertRevisionRoot(revtree1, old_path)
 
804
        self.assertRevisionRoot(revtree1, new_path)
 
805
 
 
806
    def test_rename_to_deleted_symlink_in_root(self):
 
807
        handler, branch = self.get_handler()
 
808
        old_path = 'a'
 
809
        new_path = 'b'
 
810
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
 
811
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
812
            expected_added=[(old_path,), (new_path,)])
 
813
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
814
            expected_removed=[(new_path,)],
 
815
            expected_renamed=[(old_path, new_path)])
 
816
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
 
817
        self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
 
818
        self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
 
819
        self.assertRevisionRoot(revtree1, old_path)
 
820
        self.assertRevisionRoot(revtree1, new_path)
 
821
 
 
822
    def test_rename_to_deleted_file_in_subdir(self):
 
823
        handler, branch = self.get_handler()
 
824
        old_path = 'd/a'
 
825
        new_path = 'd/b'
 
826
        handler.process(self.get_command_iter(old_path, new_path))
 
827
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
828
            expected_added=[('d',), (old_path,), (new_path,)])
 
829
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
830
            expected_removed=[(new_path,)],
 
831
            expected_renamed=[(old_path, new_path)])
 
832
        self.assertContent(branch, revtree1, old_path, "aaa")
 
833
        self.assertContent(branch, revtree1, new_path, "bbb")
 
834
        self.assertContent(branch, revtree2, new_path, "aaa")
 
835
 
 
836
    def test_rename_to_deleted_symlink_in_subdir(self):
 
837
        handler, branch = self.get_handler()
 
838
        old_path = 'd/a'
 
839
        new_path = 'd/b'
 
840
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
 
841
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
842
            expected_added=[('d',), (old_path,), (new_path,)])
 
843
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
844
            expected_removed=[(new_path,)],
 
845
            expected_renamed=[(old_path, new_path)])
 
846
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
 
847
        self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
 
848
        self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
 
849
 
 
850
    def test_rename_to_deleted_file_in_new_dir(self):
 
851
        handler, branch = self.get_handler()
 
852
        old_path = 'd1/a'
 
853
        new_path = 'd2/b'
 
854
        handler.process(self.get_command_iter(old_path, new_path))
 
855
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
856
            expected_added=[('d1',), (old_path,), ('d2',), (new_path,)])
 
857
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
858
            expected_removed=[('d1',), (new_path,)],
 
859
            expected_renamed=[(old_path, new_path)])
 
860
        self.assertContent(branch, revtree1, old_path, "aaa")
 
861
        self.assertContent(branch, revtree1, new_path, "bbb")
 
862
        self.assertContent(branch, revtree2, new_path, "aaa")
 
863
 
 
864
    def test_rename_to_deleted_symlink_in_new_dir(self):
 
865
        handler, branch = self.get_handler()
 
866
        old_path = 'd1/a'
 
867
        new_path = 'd2/b'
 
868
        handler.process(self.get_command_iter(old_path, new_path, 'symlink'))
 
869
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
870
            expected_added=[('d1',), (old_path,), ('d2',), (new_path,)])
 
871
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
872
            expected_removed=[('d1',), (new_path,)],
 
873
            expected_renamed=[(old_path, new_path)])
 
874
        self.assertSymlinkTarget(branch, revtree1, old_path, "aaa")
 
875
        self.assertSymlinkTarget(branch, revtree1, new_path, "bbb")
 
876
        self.assertSymlinkTarget(branch, revtree2, new_path, "aaa")
789
877
 
790
878
 
791
879
class TestImportToPackRenameTricky(TestCaseForGenericProcessor):