Merge lp:~aaron-whitehouse/duplicity/0-8-merge_selection_tests into lp:~duplicity-team/duplicity/0.8-series

Proposed by Aaron Whitehouse
Status: Merged
Merged at revision: 1168
Proposed branch: lp:~aaron-whitehouse/duplicity/0-8-merge_selection_tests
Merge into: lp:~duplicity-team/duplicity/0.8-series
Diff against target: 265 lines (+142/-63)
3 files modified
duplicity/backends/adbackend.py (+6/-6)
testing/functional/test_selection.py (+135/-57)
tox.ini (+1/-0)
To merge this branch: bzr merge lp:~aaron-whitehouse/duplicity/0-8-merge_selection_tests
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+314789@code.launchpad.net

Description of the change

* Merge in TestExcludeIfPresent from 0.7-series, which tests the behaviour of duplicity's --exclude-if-present option.
* Move and rename TestTrailingSlash2 test (was duplicate name) as in 0.7-series.
* Fix PEP error on adbackend.py.
* Add jottalib as a tox dep to fix pylint error.
* Remove unnecessary skipUnless Linux as per 0.7-series.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'duplicity/backends/adbackend.py'
--- duplicity/backends/adbackend.py 2016-12-29 16:33:02 +0000
+++ duplicity/backends/adbackend.py 2017-01-15 22:30:30 +0000
@@ -139,12 +139,12 @@
139 authorization_url, _ = self.http_client.authorization_url(139 authorization_url, _ = self.http_client.authorization_url(
140 self.OAUTH_AUTHORIZE_URL)140 self.OAUTH_AUTHORIZE_URL)
141141
142 print ''142 print('')
143 print ('In order to allow duplicity to access Amazon Drive, please '143 print('In order to allow duplicity to access Amazon Drive, please '
144 'open the following URL in a browser and copy the URL of the '144 'open the following URL in a browser and copy the URL of the '
145 'page you see after authorization here:')145 'page you see after authorization here:')
146 print authorization_url146 print(authorization_url)
147 print ''147 print('')
148148
149 redirected_to = (raw_input('URL of the resulting page: ')149 redirected_to = (raw_input('URL of the resulting page: ')
150 .replace('http://', 'https://', 1)).strip()150 .replace('http://', 'https://', 1)).strip()
151151
=== modified file 'testing/functional/test_selection.py'
--- testing/functional/test_selection.py 2016-12-25 22:30:31 +0000
+++ testing/functional/test_selection.py 2017-01-15 22:30:30 +0000
@@ -22,10 +22,7 @@
22import sys22import sys
23import platform23import platform
2424
25if sys.version_info < (2, 7):25import unittest
26 import unittest2 as unittest # @UnresolvedImport @UnusedImport
27else:
28 import unittest # @Reimport
2926
30from . import FunctionalTestCase27from . import FunctionalTestCase
3128
@@ -842,6 +839,57 @@
842 self.restore_and_check()839 self.restore_and_check()
843840
844841
842class TestTrailingSlash2(IncludeExcludeFunctionalTest):
843 """ This tests the behaviour of globbing strings with a trailing slash"""
844 # See Bug #1479545 (https://bugs.launchpad.net/duplicity/+bug/1479545)
845
846 def test_no_trailing_slash(self):
847 """ Test that including 1.py works as expected"""
848 self.backup("full", "testfiles/select2",
849 options=["--include", "testfiles/select2/1.py",
850 "--exclude", "**"])
851 self.restore()
852 restore_dir = 'testfiles/restore_out'
853 restored = self.directory_tree_to_list_of_lists(restore_dir)
854 self.assertEqual(restored, [['1.py']])
855
856 def test_trailing_slash(self):
857 """ Test that globs with a trailing slash only match directories"""
858 # Regression test for Bug #1479545
859 # (https://bugs.launchpad.net/duplicity/+bug/1479545)
860 self.backup("full", "testfiles/select2",
861 options=["--include", "testfiles/select2/1.py/",
862 "--exclude", "**"])
863 self.restore()
864 restore_dir = 'testfiles/restore_out'
865 restored = self.directory_tree_to_list_of_lists(restore_dir)
866 self.assertEqual(restored, [])
867
868 def test_include_files_not_subdirectories(self):
869 """ Test that a trailing slash glob followed by a * glob only matches
870 files and not subdirectories"""
871 self.backup("full", "testfiles/select2",
872 options=["--exclude", "testfiles/select2/*/",
873 "--include", "testfiles/select2/*",
874 "--exclude", "**"])
875 self.restore()
876 restore_dir = 'testfiles/restore_out'
877 restored = self.directory_tree_to_list_of_lists(restore_dir)
878 self.assertEqual(restored, [['1.doc', '1.py']])
879
880 def test_include_subdirectories_not_files(self):
881 """ Test that a trailing slash glob only matches directories"""
882 self.backup("full", "testfiles/select2",
883 options=["--include", "testfiles/select2/1/1sub1/**/",
884 "--exclude", "testfiles/select2/1/1sub1/**",
885 "--exclude", "**"])
886 self.restore()
887 restore_dir = 'testfiles/restore_out'
888 restored = self.directory_tree_to_list_of_lists(restore_dir)
889 self.assertEqual(restored, [['1'], ['1sub1'],
890 ['1sub1sub1', '1sub1sub2', '1sub1sub3']])
891
892
845class TestGlobbingReplacement(IncludeExcludeFunctionalTest):893class TestGlobbingReplacement(IncludeExcludeFunctionalTest):
846 """ This tests the behaviour of the extended shell globbing pattern replacement functions."""894 """ This tests the behaviour of the extended shell globbing pattern replacement functions."""
847 # See the manual for a description of behaviours, but in summary:895 # See the manual for a description of behaviours, but in summary:
@@ -880,55 +928,89 @@
880 self.assertEqual(restored, self.expected_restored_tree)928 self.assertEqual(restored, self.expected_restored_tree)
881929
882930
883class TestTrailingSlash(IncludeExcludeFunctionalTest):931class TestExcludeIfPresent(IncludeExcludeFunctionalTest):
884 """ This tests the behaviour of globbing strings with a trailing slash"""932 """ This tests the behaviour of duplicity's --exclude-if-present option"""
885 # See Bug #1479545 (https://bugs.launchpad.net/duplicity/+bug/1479545)933
886934 def test_exclude_if_present_baseline(self):
887 def test_no_trailing_slash(self):935 """ Test that duplicity normally backs up files"""
888 """ Test that including 1.py works as expected"""936 with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag:
889 self.backup("full", "testfiles/select2",937 tag.write("Files in this folder should not be backed up.")
890 options=["--include", "testfiles/select2/1.py",938 self.backup("full", "testfiles/select2/1/1sub1",
891 "--exclude", "**"])939 options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
892 self.restore()940 "--exclude", "**"])
893 restore_dir = 'testfiles/restore_out'941 self.restore()
894 restored = self.directory_tree_to_list_of_lists(restore_dir)942 restore_dir = 'testfiles/restore_out'
895 self.assertEqual(restored, [['1.py']])943 restored = self.directory_tree_to_list_of_lists(restore_dir)
896944 self.assertEqual(restored, [['1sub1sub1'],
897 def test_trailing_slash(self):945 ['.nobackup', '1sub1sub1_file.txt']])
898 """ Test that globs with a trailing slash only match directories"""946
899 # ToDo: Bug #1479545947 def test_exclude_if_present_excludes(self):
900 # (https://bugs.launchpad.net/duplicity/+bug/1479545)948 """ Test that duplicity excludes files with relevant tag"""
901 self.backup("full", "testfiles/select2",949 with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag:
902 options=["--include", "testfiles/select2/1.py/",950 tag.write("Files in this folder should not be backed up.")
903 "--exclude", "**"])951 self.backup("full", "testfiles/select2/1/1sub1",
904 self.restore()952 options=["--exclude-if-present", ".nobackup",
905 restore_dir = 'testfiles/restore_out'953 "--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
906 restored = self.directory_tree_to_list_of_lists(restore_dir)954 "--exclude", "**"])
907 self.assertEqual(restored, [])955 self.restore()
908956 restore_dir = 'testfiles/restore_out'
909 def test_include_files_not_subdirectories(self):957 restored = self.directory_tree_to_list_of_lists(restore_dir)
910 """ Test that a trailing slash glob followed by a * glob only matches958 self.assertEqual(restored, [])
911 files and not subdirectories"""959
912 self.backup("full", "testfiles/select2",960 def test_exclude_if_present_excludes_2(self):
913 options=["--exclude", "testfiles/select2/*/",961 """ Test that duplicity excludes files with relevant tag"""
914 "--include", "testfiles/select2/*",962 with open("testfiles/select2/1/1sub1/1sub1sub1/EXCLUDE.tag", "w") as tag:
915 "--exclude", "**"])963 tag.write("Files in this folder should also not be backed up.")
916 self.restore()964 self.backup("full", "testfiles/select2/1/1sub1",
917 restore_dir = 'testfiles/restore_out'965 options=["--exclude-if-present", "EXCLUDE.tag",
918 restored = self.directory_tree_to_list_of_lists(restore_dir)966 "--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
919 self.assertEqual(restored, [['1.doc', '1.py']])967 "--exclude", "**"])
920968 self.restore()
921 def test_include_subdirectories_not_files(self):969 restore_dir = 'testfiles/restore_out'
922 """ Test that a trailing slash glob only matches directories"""970 restored = self.directory_tree_to_list_of_lists(restore_dir)
923 self.backup("full", "testfiles/select2",971 self.assertEqual(restored, [])
924 options=["--include", "testfiles/select2/1/1sub1/**/",972
925 "--exclude", "testfiles/select2/1/1sub1/**",973
926 "--exclude", "**"])974class TestLockedFoldersNoError(IncludeExcludeFunctionalTest):
927 self.restore()975 """ This tests that inaccessible folders do not cause an error"""
928 restore_dir = 'testfiles/restore_out'976
929 restored = self.directory_tree_to_list_of_lists(restore_dir)977 @unittest.skipUnless(platform.platform().startswith('Linux'),
930 self.assertEqual(restored, [['1'], ['1sub1'],978 'Skip on non-Linux systems')
931 ['1sub1sub1', '1sub1sub2', '1sub1sub3']])979 def test_locked_baseline(self):
980 """ Test no error if locked in path but excluded"""
981 folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3"
982 initial_mode = os.stat(folder_to_lock).st_mode
983 os.chmod(folder_to_lock, 0o0000)
984 self.backup("full", "testfiles/select2/1/1sub1",
985 options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
986 "--exclude", "**"])
987 os.chmod(folder_to_lock, initial_mode)
988 self.restore()
989 restore_dir = 'testfiles/restore_out'
990 restored = self.directory_tree_to_list_of_lists(restore_dir)
991 self.assertEqual(restored, [['1sub1sub1'],
992 ['1sub1sub1_file.txt']])
993
994 @unittest.skipUnless(platform.platform().startswith('Linux'),
995 'Skip on non-Linux systems')
996 def test_locked_excl_if_present(self):
997 """ Test no error if excluded locked with --exclude-if-present"""
998 # Regression test for Bug #1620085
999 # https://bugs.launchpad.net/duplicity/+bug/1620085
1000 folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3"
1001 initial_mode = os.stat(folder_to_lock).st_mode
1002 os.chmod(folder_to_lock, 0o0000)
1003 self.backup("full", "testfiles/select2/1/1sub1",
1004 options=["--exclude-if-present", "EXCLUDE.tag",
1005 "--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
1006 "--exclude", "**"])
1007 os.chmod(folder_to_lock, initial_mode)
1008 self.restore()
1009 restore_dir = 'testfiles/restore_out'
1010 restored = self.directory_tree_to_list_of_lists(restore_dir)
1011 self.assertEqual(restored, [['1sub1sub1'],
1012 ['1sub1sub1_file.txt']])
1013
9321014
933class TestFolderIncludesFiles(IncludeExcludeFunctionalTest):1015class TestFolderIncludesFiles(IncludeExcludeFunctionalTest):
934 """ This tests that including a folder includes the files within it"""1016 """ This tests that including a folder includes the files within it"""
@@ -980,8 +1062,6 @@
980 restored = self.directory_tree_to_list_of_lists(restore_dir)1062 restored = self.directory_tree_to_list_of_lists(restore_dir)
981 self.assertEqual(restored, [])1063 self.assertEqual(restored, [])
9821064
983 @unittest.skipUnless(platform.platform().startswith('Linux'),
984 'Skip on non-Linux systems')
985 def test_excludes_files_trailing_slash(self):1065 def test_excludes_files_trailing_slash(self):
986 """Excluding a folder excludes the files within it, if ends with /"""1066 """Excluding a folder excludes the files within it, if ends with /"""
987 self.backup("full", "testfiles/select2/1/1sub1",1067 self.backup("full", "testfiles/select2/1/1sub1",
@@ -994,8 +1074,6 @@
994 restore_dir = 'testfiles/restore_out'1074 restore_dir = 'testfiles/restore_out'
995 restored = self.directory_tree_to_list_of_lists(restore_dir)1075 restored = self.directory_tree_to_list_of_lists(restore_dir)
996 self.assertEqual(restored, [])1076 self.assertEqual(restored, [])
997 @unittest.skipUnless(platform.platform().startswith('Linux'),
998 'Skip on non-Linux systems')
9991077
1000 def test_excludes_files_trailing_slash_globbing_chars(self):1078 def test_excludes_files_trailing_slash_globbing_chars(self):
1001 """Tests folder excludes with globbing char and /"""1079 """Tests folder excludes with globbing char and /"""
10021080
=== modified file 'tox.ini'
--- tox.ini 2016-07-02 19:33:34 +0000
+++ tox.ini 2017-01-15 22:30:30 +0000
@@ -7,6 +7,7 @@
7deps=7deps=
8 mock8 mock
9 pexpect9 pexpect
10 jottalib
1011
11[testenv:lpbuildd-precise]12[testenv:lpbuildd-precise]
12setenv=13setenv=

Subscribers

People subscribed via source and target branches