~overlordtm/duplicity/koofr

« back to all changes in this revision

Viewing changes to testing/functional/test_selection.py

  • Committer: Kenneth Loafman
  • Date: 2015-01-31 17:17:29 UTC
  • mfrom: (1065.2.2 duplicity_bug_932482)
  • Revision ID: kenneth@loafman.com-20150131171729-ma0k52e7sag45pym
* Merged in lp:~aaron-whitehouse/duplicity/bug_932482_trailing_slashes_and_wildcards_error
  - Added functional and unit tests to show Bug #932482 - that selection does
    not work correctly when excludes (in a filelist or in a commandline option)
    contain both a single or double asterisk and a trailing slash.

Show diffs side-by-side

added added

removed removed

Lines of Context:
582
582
        restored = self.directory_tree_to_list_of_lists(restore_dir)
583
583
        self.assertEqual(restored, self.expected_restored_tree)
584
584
 
 
585
 
585
586
class TestIncludeExcludedForContents(IncludeExcludeFunctionalTest):
586
587
    """ Test to check that folders that are excluded are included if they contain includes of higher priority.
587
588
     Exhibits the issue reported in Bug #1408411 (https://bugs.launchpad.net/duplicity/+bug/1408411). """
639
640
        self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/exclude.txt"])
640
641
        self.restore_and_check()
641
642
 
 
643
 
 
644
class TestAsterisks(IncludeExcludeFunctionalTest):
 
645
    """ Test to check that asterisks work as expected
 
646
     Exhibits the issue reported in Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371).
 
647
     See the unit tests for more granularity on the issue."""
 
648
 
 
649
    def restore_and_check(self):
 
650
        """Restores the backup and compares to what is expected."""
 
651
        self.restore()
 
652
        restore_dir = 'testfiles/restore_out'
 
653
        restored = self.directory_tree_to_list_of_lists(restore_dir)
 
654
        self.assertEqual(restored, [['2'], ['1']])
 
655
 
 
656
    def test_exclude_globbing_filelist_asterisks_none(self):
 
657
        """Basic exclude globbing filelist."""
 
658
        with open("testfiles/filelist.txt", 'w') as f:
 
659
            f.write("+ testfiles/select/1/2/1\n"
 
660
                    "- testfiles/select/1/2\n"
 
661
                    "- testfiles/select/1/1\n"
 
662
                    "- testfiles/select/1/3")
 
663
        self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
 
664
        self.restore_and_check()
 
665
 
 
666
    @unittest.expectedFailure
 
667
    def test_exclude_globbing_filelist_asterisks_single(self):
 
668
        """Exclude globbing filelist with asterisks replacing folders."""
 
669
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
670
        with open("testfiles/filelist.txt", 'w') as f:
 
671
            f.write("+ */select/1/2/1\n"
 
672
                    "- */select/1/2\n"
 
673
                    "- testfiles/*/1/1\n"
 
674
                    "- */*/1/3")
 
675
        self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
 
676
        self.restore_and_check()
 
677
 
 
678
    @unittest.expectedFailure
 
679
    def test_exclude_globbing_filelist_asterisks_double_asterisks(self):
 
680
        """Exclude globbing filelist with double asterisks replacing folders."""
 
681
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
682
        with open("testfiles/filelist.txt", 'w') as f:
 
683
            f.write("+ **/1/2/1\n"
 
684
                    "- **/1/2\n"
 
685
                    "- **/select/1/1\n"
 
686
                    "- testfiles/select/1/3")
 
687
        self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
 
688
        self.restore_and_check()
 
689
 
 
690
    def test_commandline_asterisks_single_excludes_only(self):
 
691
        """test_commandline_include_exclude with single asterisks on exclude lines."""
 
692
        self.backup("full", "testfiles/select/1",
 
693
                    options=["--include", "testfiles/select/1/2/1",
 
694
                             "--exclude", "testfiles/*/1/2",
 
695
                             "--exclude", "*/select/1/1",
 
696
                             "--exclude", "*/select/1/3"])
 
697
        self.restore_and_check()
 
698
 
 
699
    @unittest.expectedFailure
 
700
    def test_commandline_asterisks_single_both(self):
 
701
        """test_commandline_include_exclude with single asterisks on both exclude and include lines."""
 
702
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
703
        self.backup("full", "testfiles/select/1",
 
704
                    options=["--include", "*/select/1/2/1",
 
705
                             "--exclude", "testfiles/*/1/2",
 
706
                             "--exclude", "*/select/1/1",
 
707
                             "--exclude", "*/select/1/3"])
 
708
        self.restore_and_check()
 
709
 
 
710
    def test_commandline_asterisks_double_exclude_only(self):
 
711
        """test_commandline_include_exclude with double asterisks on exclude lines."""
 
712
        self.backup("full", "testfiles/select/1",
 
713
                    options=["--include", "testfiles/select/1/2/1",
 
714
                             "--exclude", "**/1/2",
 
715
                             "--exclude", "**/1/1",
 
716
                             "--exclude", "**/1/3"])
 
717
        self.restore_and_check()
 
718
 
 
719
    @unittest.expectedFailure
 
720
    def test_commandline_asterisks_double_both(self):
 
721
        """test_commandline_include_exclude with double asterisks on both exclude and include lines."""
 
722
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
723
        self.backup("full", "testfiles/select/1",
 
724
                    options=["--include", "**/1/2/1",
 
725
                             "--exclude", "**/1/2",
 
726
                             "--exclude", "**/1/1",
 
727
                             "--exclude", "**/1/3"])
 
728
        self.restore_and_check()
 
729
 
 
730
class TestTrailingSlash(IncludeExcludeFunctionalTest):
 
731
    """ Test to check that a trailing slash works as expected
 
732
     Exhibits the issue reported in Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)."""
 
733
 
 
734
    def restore_and_check(self):
 
735
        """Restores the backup and compares to what is expected."""
 
736
        self.restore()
 
737
        restore_dir = 'testfiles/restore_out'
 
738
        restored = self.directory_tree_to_list_of_lists(restore_dir)
 
739
        self.assertEqual(restored, [['2'], ['1']])
 
740
 
 
741
    def test_exclude_globbing_filelist_trailing_slashes(self):
 
742
        """test_exclude_globbing_filelist_asterisks_none with trailing slashes."""
 
743
        with open("testfiles/filelist.txt", 'w') as f:
 
744
            f.write("+ testfiles/select/1/2/1/\n"
 
745
                    "- testfiles/select/1/2/\n"
 
746
                    "- testfiles/select/1/1/\n"
 
747
                    "- testfiles/select/1/3/")
 
748
        self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
 
749
        self.restore_and_check()
 
750
 
 
751
    @unittest.expectedFailure
 
752
    def test_exclude_globbing_filelist_trailing_slashes_single_wildcards_excludes(self):
 
753
        """test_exclude_globbing_filelist_trailing_slashes with single wildcards in excludes."""
 
754
        # Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
 
755
        with open("testfiles/filelist.txt", 'w') as f:
 
756
            f.write("+ testfiles/select/1/2/1/\n"
 
757
                    "- */select/1/2/\n"
 
758
                    "- testfiles/*/1/1/\n"
 
759
                    "- */*/1/3/")
 
760
        self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
 
761
        self.restore_and_check()
 
762
 
 
763
    @unittest.expectedFailure
 
764
    def test_exclude_globbing_filelist_trailing_slashes_double_wildcards_excludes(self):
 
765
        """test_exclude_globbing_filelist_trailing_slashes with double wildcards in excludes."""
 
766
        # Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
 
767
        with open("testfiles/filelist.txt", 'w') as f:
 
768
            f.write("+ testfiles/select/1/2/1/\n"
 
769
                    "- **/1/2/\n"
 
770
                    "- **/1/1/\n"
 
771
                    "- **/1/3/")
 
772
        self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
 
773
        self.restore_and_check()
 
774
 
 
775
    @unittest.expectedFailure
 
776
    def test_exclude_globbing_filelist_trailing_slashes_double_wildcards_excludes(self):
 
777
        """test_exclude_globbing_filelist_trailing_slashes with double wildcards in excludes."""
 
778
        # Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) and likely
 
779
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
780
        with open("testfiles/filelist.txt", 'w') as f:
 
781
            f.write("+ **/1/2/1/\n"
 
782
                    "- **/1/2/\n"
 
783
                    "- **/1/1/\n"
 
784
                    "- **/1/3/")
 
785
        self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
 
786
        self.restore_and_check()
 
787
 
 
788
    @unittest.expectedFailure
 
789
    def test_exclude_globbing_filelist_trailing_slashes_wildcards(self):
 
790
        """test_commandline_asterisks_single_excludes_only with trailing slashes."""
 
791
         # Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
 
792
        self.backup("full", "testfiles/select/1",
 
793
                    options=["--include", "testfiles/select/1/2/1/",
 
794
                             "--exclude", "testfiles/*/1/2/",
 
795
                             "--exclude", "*/select/1/1/",
 
796
                             "--exclude", "*/select/1/3/"])
 
797
        self.restore_and_check()
 
798
 
 
799
 
 
800
 
642
801
if __name__ == "__main__":
643
802
    unittest.main()