~overlordtm/duplicity/koofr

« back to all changes in this revision

Viewing changes to testing/unit/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:
682
682
                        '- testfiles/select/1\n'
683
683
                        '- **'])
684
684
 
 
685
    def test_include_globbing_filelist_asterisk(self):
 
686
        """Filelist glob test with * instead of 'testfiles'"""
 
687
        # Thank you to Elifarley Cruz for this test case
 
688
        # (https://bugs.launchpad.net/duplicity/+bug/884371).
 
689
        self.ParseTest([("--include-globbing-filelist", "file")],
 
690
                       [(), ('1',), ('1', '1'), ('1', '1', '1'),
 
691
                        ('1', '1', '2'), ('1', '1', '3')],
 
692
                       ["*/select/1/1\n"
 
693
                        "- **"])
 
694
 
 
695
    def test_include_globbing_filelist_asterisk_2(self):
 
696
        """Identical to test_globbing_filelist, but with the exclude 'select' replaced with '*'"""
 
697
        self.ParseTest([("--include-globbing-filelist", "file")],
 
698
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
699
                        ('1', '1', '3')],
 
700
                       ["- testfiles/*/1/1/1\n"
 
701
                        "testfiles/select/1/1\n"
 
702
                        "- testfiles/select/1\n"
 
703
                        "- **"])
 
704
 
 
705
    @unittest.expectedFailure
 
706
    def test_include_globbing_filelist_asterisk_3(self):
 
707
        """Identical to test_globbing_filelist, but with the auto-include 'select' replaced with '*'"""
 
708
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
709
        self.ParseTest([("--include-globbing-filelist", "file")],
 
710
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
711
                        ('1', '1', '3')],
 
712
                       ["- testfiles/select/1/1/1\n"
 
713
                        "testfiles/*/1/1\n"
 
714
                        "- testfiles/select/1\n"
 
715
                        "- **"])
 
716
 
 
717
    @unittest.expectedFailure
 
718
    def test_include_globbing_filelist_asterisk_4(self):
 
719
        """Identical to test_globbing_filelist, but with a specific include 'select' replaced with '*'"""
 
720
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
721
        self.ParseTest([("--include-globbing-filelist", "file")],
 
722
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
723
                        ('1', '1', '3')],
 
724
                       ["- testfiles/select/1/1/1\n"
 
725
                        "+ testfiles/*/1/1\n"
 
726
                        "- testfiles/select/1\n"
 
727
                        "- **"])
 
728
 
 
729
    @unittest.expectedFailure
 
730
    def test_include_globbing_filelist_asterisk_5(self):
 
731
        """Identical to test_globbing_filelist, but with all 'select's replaced with '*'"""
 
732
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
733
        self.ParseTest([("--include-globbing-filelist", "file")],
 
734
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
735
                        ('1', '1', '3')],
 
736
                       ["- testfiles/*/1/1/1\n"
 
737
                        "+ testfiles/*/1/1\n"
 
738
                        "- testfiles/*/1\n"
 
739
                        "- **"])
 
740
 
 
741
    def test_include_globbing_filelist_asterisk_6(self):
 
742
        """Identical to test_globbing_filelist, but with numerous excluded folders replaced with '*'"""
 
743
        self.ParseTest([("--include-globbing-filelist", "file")],
 
744
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
745
                        ('1', '1', '3')],
 
746
                       ["- */*/1/1/1\n"
 
747
                        "+ testfiles/select/1/1\n"
 
748
                        "- */*/1\n"
 
749
                        "- **"])
 
750
 
 
751
    @unittest.expectedFailure
 
752
    def test_include_globbing_filelist_asterisk_7(self):
 
753
        """Identical to test_globbing_filelist, but with numerous included/excluded folders replaced with '*'"""
 
754
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
755
        self.ParseTest([("--include-globbing-filelist", "file")],
 
756
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
757
                        ('1', '1', '3')],
 
758
                       ["- */*/1/1/1\n"
 
759
                        "+ */*/1/1\n"
 
760
                        "- */*/1\n"
 
761
                        "- **"])
 
762
 
 
763
 
 
764
    def test_include_globbing_filelist_double_asterisk_1(self):
 
765
        """Identical to test_globbing_filelist, but with the exclude 'select' replaced with '**'"""
 
766
        self.ParseTest([("--include-globbing-filelist", "file")],
 
767
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
768
                        ('1', '1', '3')],
 
769
                       ["- testfiles/**/1/1/1\n"
 
770
                        "testfiles/select/1/1\n"
 
771
                        "- testfiles/select/1\n"
 
772
                        "- **"])
 
773
 
 
774
    @unittest.expectedFailure
 
775
    def test_include_globbing_filelist_double_asterisk_2(self):
 
776
        """Identical to test_globbing_filelist, but with the include 'select' replaced with '**'"""
 
777
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
778
        self.ParseTest([("--include-globbing-filelist", "file")],
 
779
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
780
                        ('1', '1', '3')],
 
781
                       ["- testfiles/select/1/1/1\n"
 
782
                        "testfiles/**/1/1\n"
 
783
                        "- testfiles/select/1\n"
 
784
                        "- **"])
 
785
 
 
786
    def test_include_globbing_filelist_double_asterisk_3(self):
 
787
        """Identical to test_globbing_filelist, but with the exclude 'testfiles/select' replaced with '**'"""
 
788
        self.ParseTest([("--include-globbing-filelist", "file")],
 
789
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
790
                        ('1', '1', '3')],
 
791
                       ["- **/1/1/1\n"
 
792
                        "testfiles/select/1/1\n"
 
793
                        "- testfiles/select/1\n"
 
794
                        "- **"])
 
795
 
 
796
    @unittest.expectedFailure
 
797
    def test_include_globbing_filelist_double_asterisk_4(self):
 
798
        """Identical to test_globbing_filelist, but with the include 'testfiles/select' replaced with '**'"""
 
799
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
800
        self.ParseTest([("--include-globbing-filelist", "file")],
 
801
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
802
                        ('1', '1', '3')],
 
803
                       ["- testfiles/select/1/1/1\n"
 
804
                        "**/1/1\n"
 
805
                        "- testfiles/select/1\n"
 
806
                        "- **"])
 
807
 
 
808
    @unittest.expectedFailure
 
809
    def test_include_globbing_filelist_double_asterisk_5(self):
 
810
        """Identical to test_globbing_filelist, but with all 'testfiles/select's replaced with '**'"""
 
811
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
812
        self.ParseTest([("--include-globbing-filelist", "file")],
 
813
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
814
                        ('1', '1', '3')],
 
815
                       ["- **/1/1/1\n"
 
816
                        "**/1/1\n"
 
817
                        "- **/1\n"
 
818
                        "- **"])
 
819
 
 
820
    def test_include_globbing_filelist_trailing_slashes(self):
 
821
        """Filelist glob test similar to globbing filelist, but with trailing slashes"""
 
822
        self.ParseTest([("--include-globbing-filelist", "file")],
 
823
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
824
                        ('1', '1', '3')],
 
825
                       ["- testfiles/select/1/1/1/\n"
 
826
                        "testfiles/select/1/1/\n"
 
827
                        "- testfiles/select/1/\n"
 
828
                        "- **"])
 
829
 
 
830
    @unittest.expectedFailure
 
831
    def test_include_globbing_filelist_trailing_slashes_and_single_asterisks(self):
 
832
        """Filelist glob test similar to globbing filelist, but with trailing slashes and single asterisks"""
 
833
        # Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
 
834
        self.ParseTest([("--include-globbing-filelist", "file")],
 
835
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
836
                        ('1', '1', '3')],
 
837
                       ["- */select/1/1/1/\n"
 
838
                        "testfiles/select/1/1/\n"
 
839
                        "- testfiles/*/1/\n"
 
840
                        "- **"])
 
841
 
 
842
    @unittest.expectedFailure
 
843
    def test_include_globbing_filelist_trailing_slashes_and_double_asterisks(self):
 
844
        """Filelist glob test similar to globbing filelist, but with trailing slashes and double asterisks"""
 
845
        # Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
 
846
        self.ParseTest([("--include-globbing-filelist", "file")],
 
847
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
848
                        ('1', '1', '3')],
 
849
                       ["- **/1/1/1/\n"
 
850
                        "testfiles/select/1/1/\n"
 
851
                        "- **/1/\n"
 
852
                        "- **"])
 
853
 
 
854
    def test_exclude_globbing_filelist(self):
 
855
        """Exclude version of test_globbing_filelist"""
 
856
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
857
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
858
                        ('1', '1', '3')],
 
859
                       ["testfiles/select/1/1/1\n"
 
860
                        "+ testfiles/select/1/1\n"
 
861
                        "testfiles/select/1\n"
 
862
                        "- **"])
 
863
 
 
864
    def test_exclude_globbing_filelist_asterisk_1(self):
 
865
        """Exclude version of test_include_globbing_filelist_asterisk"""
 
866
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
867
                       [(), ('1',), ('1', '1'), ('1', '1', '1'),
 
868
                        ('1', '1', '2'), ('1', '1', '3')],
 
869
                       ["+ */select/1/1\n"
 
870
                        "- **"])
 
871
 
 
872
    def test_exclude_globbing_filelist_asterisk_2(self):
 
873
        """Identical to test_exclude_globbing_filelist, but with the exclude 'select' replaced with '*'"""
 
874
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
875
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
876
                        ('1', '1', '3')],
 
877
                       ["testfiles/*/1/1/1\n"
 
878
                        "+ testfiles/select/1/1\n"
 
879
                        "testfiles/select/1\n"
 
880
                        "- **"])
 
881
 
 
882
    @unittest.expectedFailure
 
883
    def test_exclude_globbing_filelist_asterisk_3(self):
 
884
        """Identical to test_exclude_globbing_filelist, but with the include 'select' replaced with '*'"""
 
885
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
886
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
887
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
888
                        ('1', '1', '3')],
 
889
                       ["testfiles/select/1/1/1\n"
 
890
                        "+ testfiles/*/1/1\n"
 
891
                        "testfiles/select/1\n"
 
892
                        "- **"])
 
893
 
 
894
    def test_exclude_globbing_filelist_asterisk_4(self):
 
895
        """Identical to test_exclude_globbing_filelist, but with numerous excluded folders replaced with '*'"""
 
896
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
897
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
898
                        ('1', '1', '3')],
 
899
                       ["*/select/1/1/1\n"
 
900
                        "+ testfiles/select/1/1\n"
 
901
                        "*/*/1\n"
 
902
                        "- **"])
 
903
 
 
904
    @unittest.expectedFailure
 
905
    def test_exclude_globbing_filelist_asterisk_5(self):
 
906
        """Identical to test_exclude_globbing_filelist, but with numerous included/excluded folders replaced with '*'"""
 
907
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
908
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
909
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
910
                        ('1', '1', '3')],
 
911
                       ["*/select/1/1/1\n"
 
912
                        "+ */*/1/1\n"
 
913
                        "*/*/1\n"
 
914
                        "- **"])
 
915
 
 
916
    @unittest.expectedFailure
 
917
    def test_exclude_globbing_filelist_double_asterisk(self):
 
918
        """Identical to test_exclude_globbing_filelist, but with all included/excluded folders replaced with '**'"""
 
919
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
 
920
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
921
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
922
                        ('1', '1', '3')],
 
923
                       ["**/1/1/1\n"
 
924
                        "+ **/1/1\n"
 
925
                        "**/1\n"
 
926
                        "- **"])
 
927
 
685
928
    def testGlob(self):
686
929
        """Test globbing expression"""
687
930
        self.ParseTest([("--exclude", "**[3-5]"),