639
640
self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/exclude.txt"])
640
641
self.restore_and_check()
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."""
649
def restore_and_check(self):
650
"""Restores the backup and compares to what is expected."""
652
restore_dir = 'testfiles/restore_out'
653
restored = self.directory_tree_to_list_of_lists(restore_dir)
654
self.assertEqual(restored, [['2'], ['1']])
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()
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"
673
"- testfiles/*/1/1\n"
675
self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
676
self.restore_and_check()
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"
686
"- testfiles/select/1/3")
687
self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
688
self.restore_and_check()
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()
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()
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()
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()
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)."""
734
def restore_and_check(self):
735
"""Restores the backup and compares to what is expected."""
737
restore_dir = 'testfiles/restore_out'
738
restored = self.directory_tree_to_list_of_lists(restore_dir)
739
self.assertEqual(restored, [['2'], ['1']])
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()
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"
758
"- testfiles/*/1/1/\n"
760
self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
761
self.restore_and_check()
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"
772
self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
773
self.restore_and_check()
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"
785
self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
786
self.restore_and_check()
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()
642
801
if __name__ == "__main__":