Merge lp:~aaron-whitehouse/duplicity/0-8-merge_selection_tests into lp:~duplicity-team/duplicity/0.8-series
- 0-8-merge_selection_tests
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
duplicity-team | Pending | ||
Review via email: mp+314789@code.launchpad.net |
Commit message
Description of the change
* Merge in TestExcludeIfPr
* 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
1 | === modified file 'duplicity/backends/adbackend.py' | |||
2 | --- duplicity/backends/adbackend.py 2016-12-29 16:33:02 +0000 | |||
3 | +++ duplicity/backends/adbackend.py 2017-01-15 22:30:30 +0000 | |||
4 | @@ -139,12 +139,12 @@ | |||
5 | 139 | authorization_url, _ = self.http_client.authorization_url( | 139 | authorization_url, _ = self.http_client.authorization_url( |
6 | 140 | self.OAUTH_AUTHORIZE_URL) | 140 | self.OAUTH_AUTHORIZE_URL) |
7 | 141 | 141 | ||
14 | 142 | print '' | 142 | print('') |
15 | 143 | print ('In order to allow duplicity to access Amazon Drive, please ' | 143 | print('In order to allow duplicity to access Amazon Drive, please ' |
16 | 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 ' |
17 | 145 | 'page you see after authorization here:') | 145 | 'page you see after authorization here:') |
18 | 146 | print authorization_url | 146 | print(authorization_url) |
19 | 147 | print '' | 147 | print('') |
20 | 148 | 148 | ||
21 | 149 | redirected_to = (raw_input('URL of the resulting page: ') | 149 | redirected_to = (raw_input('URL of the resulting page: ') |
22 | 150 | .replace('http://', 'https://', 1)).strip() | 150 | .replace('http://', 'https://', 1)).strip() |
23 | 151 | 151 | ||
24 | === modified file 'testing/functional/test_selection.py' | |||
25 | --- testing/functional/test_selection.py 2016-12-25 22:30:31 +0000 | |||
26 | +++ testing/functional/test_selection.py 2017-01-15 22:30:30 +0000 | |||
27 | @@ -22,10 +22,7 @@ | |||
28 | 22 | import sys | 22 | import sys |
29 | 23 | import platform | 23 | import platform |
30 | 24 | 24 | ||
35 | 25 | if sys.version_info < (2, 7): | 25 | import unittest |
32 | 26 | import unittest2 as unittest # @UnresolvedImport @UnusedImport | ||
33 | 27 | else: | ||
34 | 28 | import unittest # @Reimport | ||
36 | 29 | 26 | ||
37 | 30 | from . import FunctionalTestCase | 27 | from . import FunctionalTestCase |
38 | 31 | 28 | ||
39 | @@ -842,6 +839,57 @@ | |||
40 | 842 | self.restore_and_check() | 839 | self.restore_and_check() |
41 | 843 | 840 | ||
42 | 844 | 841 | ||
43 | 842 | class TestTrailingSlash2(IncludeExcludeFunctionalTest): | ||
44 | 843 | """ This tests the behaviour of globbing strings with a trailing slash""" | ||
45 | 844 | # See Bug #1479545 (https://bugs.launchpad.net/duplicity/+bug/1479545) | ||
46 | 845 | |||
47 | 846 | def test_no_trailing_slash(self): | ||
48 | 847 | """ Test that including 1.py works as expected""" | ||
49 | 848 | self.backup("full", "testfiles/select2", | ||
50 | 849 | options=["--include", "testfiles/select2/1.py", | ||
51 | 850 | "--exclude", "**"]) | ||
52 | 851 | self.restore() | ||
53 | 852 | restore_dir = 'testfiles/restore_out' | ||
54 | 853 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
55 | 854 | self.assertEqual(restored, [['1.py']]) | ||
56 | 855 | |||
57 | 856 | def test_trailing_slash(self): | ||
58 | 857 | """ Test that globs with a trailing slash only match directories""" | ||
59 | 858 | # Regression test for Bug #1479545 | ||
60 | 859 | # (https://bugs.launchpad.net/duplicity/+bug/1479545) | ||
61 | 860 | self.backup("full", "testfiles/select2", | ||
62 | 861 | options=["--include", "testfiles/select2/1.py/", | ||
63 | 862 | "--exclude", "**"]) | ||
64 | 863 | self.restore() | ||
65 | 864 | restore_dir = 'testfiles/restore_out' | ||
66 | 865 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
67 | 866 | self.assertEqual(restored, []) | ||
68 | 867 | |||
69 | 868 | def test_include_files_not_subdirectories(self): | ||
70 | 869 | """ Test that a trailing slash glob followed by a * glob only matches | ||
71 | 870 | files and not subdirectories""" | ||
72 | 871 | self.backup("full", "testfiles/select2", | ||
73 | 872 | options=["--exclude", "testfiles/select2/*/", | ||
74 | 873 | "--include", "testfiles/select2/*", | ||
75 | 874 | "--exclude", "**"]) | ||
76 | 875 | self.restore() | ||
77 | 876 | restore_dir = 'testfiles/restore_out' | ||
78 | 877 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
79 | 878 | self.assertEqual(restored, [['1.doc', '1.py']]) | ||
80 | 879 | |||
81 | 880 | def test_include_subdirectories_not_files(self): | ||
82 | 881 | """ Test that a trailing slash glob only matches directories""" | ||
83 | 882 | self.backup("full", "testfiles/select2", | ||
84 | 883 | options=["--include", "testfiles/select2/1/1sub1/**/", | ||
85 | 884 | "--exclude", "testfiles/select2/1/1sub1/**", | ||
86 | 885 | "--exclude", "**"]) | ||
87 | 886 | self.restore() | ||
88 | 887 | restore_dir = 'testfiles/restore_out' | ||
89 | 888 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
90 | 889 | self.assertEqual(restored, [['1'], ['1sub1'], | ||
91 | 890 | ['1sub1sub1', '1sub1sub2', '1sub1sub3']]) | ||
92 | 891 | |||
93 | 892 | |||
94 | 845 | class TestGlobbingReplacement(IncludeExcludeFunctionalTest): | 893 | class TestGlobbingReplacement(IncludeExcludeFunctionalTest): |
95 | 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.""" |
96 | 847 | # See the manual for a description of behaviours, but in summary: | 895 | # See the manual for a description of behaviours, but in summary: |
97 | @@ -880,55 +928,89 @@ | |||
98 | 880 | self.assertEqual(restored, self.expected_restored_tree) | 928 | self.assertEqual(restored, self.expected_restored_tree) |
99 | 881 | 929 | ||
100 | 882 | 930 | ||
150 | 883 | class TestTrailingSlash(IncludeExcludeFunctionalTest): | 931 | class TestExcludeIfPresent(IncludeExcludeFunctionalTest): |
151 | 884 | """ This tests the behaviour of globbing strings with a trailing slash""" | 932 | """ This tests the behaviour of duplicity's --exclude-if-present option""" |
152 | 885 | # See Bug #1479545 (https://bugs.launchpad.net/duplicity/+bug/1479545) | 933 | |
153 | 886 | 934 | def test_exclude_if_present_baseline(self): | |
154 | 887 | def test_no_trailing_slash(self): | 935 | """ Test that duplicity normally backs up files""" |
155 | 888 | """ Test that including 1.py works as expected""" | 936 | with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag: |
156 | 889 | self.backup("full", "testfiles/select2", | 937 | tag.write("Files in this folder should not be backed up.") |
157 | 890 | options=["--include", "testfiles/select2/1.py", | 938 | self.backup("full", "testfiles/select2/1/1sub1", |
158 | 891 | "--exclude", "**"]) | 939 | options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*", |
159 | 892 | self.restore() | 940 | "--exclude", "**"]) |
160 | 893 | restore_dir = 'testfiles/restore_out' | 941 | self.restore() |
161 | 894 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 942 | restore_dir = 'testfiles/restore_out' |
162 | 895 | self.assertEqual(restored, [['1.py']]) | 943 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
163 | 896 | 944 | self.assertEqual(restored, [['1sub1sub1'], | |
164 | 897 | def test_trailing_slash(self): | 945 | ['.nobackup', '1sub1sub1_file.txt']]) |
165 | 898 | """ Test that globs with a trailing slash only match directories""" | 946 | |
166 | 899 | # ToDo: Bug #1479545 | 947 | def test_exclude_if_present_excludes(self): |
167 | 900 | # (https://bugs.launchpad.net/duplicity/+bug/1479545) | 948 | """ Test that duplicity excludes files with relevant tag""" |
168 | 901 | self.backup("full", "testfiles/select2", | 949 | with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag: |
169 | 902 | options=["--include", "testfiles/select2/1.py/", | 950 | tag.write("Files in this folder should not be backed up.") |
170 | 903 | "--exclude", "**"]) | 951 | self.backup("full", "testfiles/select2/1/1sub1", |
171 | 904 | self.restore() | 952 | options=["--exclude-if-present", ".nobackup", |
172 | 905 | restore_dir = 'testfiles/restore_out' | 953 | "--include", "testfiles/select2/1/1sub1/1sub1sub1/*", |
173 | 906 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 954 | "--exclude", "**"]) |
174 | 907 | self.assertEqual(restored, []) | 955 | self.restore() |
175 | 908 | 956 | restore_dir = 'testfiles/restore_out' | |
176 | 909 | def test_include_files_not_subdirectories(self): | 957 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
177 | 910 | """ Test that a trailing slash glob followed by a * glob only matches | 958 | self.assertEqual(restored, []) |
178 | 911 | files and not subdirectories""" | 959 | |
179 | 912 | self.backup("full", "testfiles/select2", | 960 | def test_exclude_if_present_excludes_2(self): |
180 | 913 | options=["--exclude", "testfiles/select2/*/", | 961 | """ Test that duplicity excludes files with relevant tag""" |
181 | 914 | "--include", "testfiles/select2/*", | 962 | with open("testfiles/select2/1/1sub1/1sub1sub1/EXCLUDE.tag", "w") as tag: |
182 | 915 | "--exclude", "**"]) | 963 | tag.write("Files in this folder should also not be backed up.") |
183 | 916 | self.restore() | 964 | self.backup("full", "testfiles/select2/1/1sub1", |
184 | 917 | restore_dir = 'testfiles/restore_out' | 965 | options=["--exclude-if-present", "EXCLUDE.tag", |
185 | 918 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 966 | "--include", "testfiles/select2/1/1sub1/1sub1sub1/*", |
186 | 919 | self.assertEqual(restored, [['1.doc', '1.py']]) | 967 | "--exclude", "**"]) |
187 | 920 | 968 | self.restore() | |
188 | 921 | def test_include_subdirectories_not_files(self): | 969 | restore_dir = 'testfiles/restore_out' |
189 | 922 | """ Test that a trailing slash glob only matches directories""" | 970 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
190 | 923 | self.backup("full", "testfiles/select2", | 971 | self.assertEqual(restored, []) |
191 | 924 | options=["--include", "testfiles/select2/1/1sub1/**/", | 972 | |
192 | 925 | "--exclude", "testfiles/select2/1/1sub1/**", | 973 | |
193 | 926 | "--exclude", "**"]) | 974 | class TestLockedFoldersNoError(IncludeExcludeFunctionalTest): |
194 | 927 | self.restore() | 975 | """ This tests that inaccessible folders do not cause an error""" |
195 | 928 | restore_dir = 'testfiles/restore_out' | 976 | |
196 | 929 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 977 | @unittest.skipUnless(platform.platform().startswith('Linux'), |
197 | 930 | self.assertEqual(restored, [['1'], ['1sub1'], | 978 | 'Skip on non-Linux systems') |
198 | 931 | ['1sub1sub1', '1sub1sub2', '1sub1sub3']]) | 979 | def test_locked_baseline(self): |
199 | 980 | """ Test no error if locked in path but excluded""" | ||
200 | 981 | folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3" | ||
201 | 982 | initial_mode = os.stat(folder_to_lock).st_mode | ||
202 | 983 | os.chmod(folder_to_lock, 0o0000) | ||
203 | 984 | self.backup("full", "testfiles/select2/1/1sub1", | ||
204 | 985 | options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*", | ||
205 | 986 | "--exclude", "**"]) | ||
206 | 987 | os.chmod(folder_to_lock, initial_mode) | ||
207 | 988 | self.restore() | ||
208 | 989 | restore_dir = 'testfiles/restore_out' | ||
209 | 990 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
210 | 991 | self.assertEqual(restored, [['1sub1sub1'], | ||
211 | 992 | ['1sub1sub1_file.txt']]) | ||
212 | 993 | |||
213 | 994 | @unittest.skipUnless(platform.platform().startswith('Linux'), | ||
214 | 995 | 'Skip on non-Linux systems') | ||
215 | 996 | def test_locked_excl_if_present(self): | ||
216 | 997 | """ Test no error if excluded locked with --exclude-if-present""" | ||
217 | 998 | # Regression test for Bug #1620085 | ||
218 | 999 | # https://bugs.launchpad.net/duplicity/+bug/1620085 | ||
219 | 1000 | folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3" | ||
220 | 1001 | initial_mode = os.stat(folder_to_lock).st_mode | ||
221 | 1002 | os.chmod(folder_to_lock, 0o0000) | ||
222 | 1003 | self.backup("full", "testfiles/select2/1/1sub1", | ||
223 | 1004 | options=["--exclude-if-present", "EXCLUDE.tag", | ||
224 | 1005 | "--include", "testfiles/select2/1/1sub1/1sub1sub1/*", | ||
225 | 1006 | "--exclude", "**"]) | ||
226 | 1007 | os.chmod(folder_to_lock, initial_mode) | ||
227 | 1008 | self.restore() | ||
228 | 1009 | restore_dir = 'testfiles/restore_out' | ||
229 | 1010 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
230 | 1011 | self.assertEqual(restored, [['1sub1sub1'], | ||
231 | 1012 | ['1sub1sub1_file.txt']]) | ||
232 | 1013 | |||
233 | 932 | 1014 | ||
234 | 933 | class TestFolderIncludesFiles(IncludeExcludeFunctionalTest): | 1015 | class TestFolderIncludesFiles(IncludeExcludeFunctionalTest): |
235 | 934 | """ This tests that including a folder includes the files within it""" | 1016 | """ This tests that including a folder includes the files within it""" |
236 | @@ -980,8 +1062,6 @@ | |||
237 | 980 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1062 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
238 | 981 | self.assertEqual(restored, []) | 1063 | self.assertEqual(restored, []) |
239 | 982 | 1064 | ||
240 | 983 | @unittest.skipUnless(platform.platform().startswith('Linux'), | ||
241 | 984 | 'Skip on non-Linux systems') | ||
242 | 985 | def test_excludes_files_trailing_slash(self): | 1065 | def test_excludes_files_trailing_slash(self): |
243 | 986 | """Excluding a folder excludes the files within it, if ends with /""" | 1066 | """Excluding a folder excludes the files within it, if ends with /""" |
244 | 987 | self.backup("full", "testfiles/select2/1/1sub1", | 1067 | self.backup("full", "testfiles/select2/1/1sub1", |
245 | @@ -994,8 +1074,6 @@ | |||
246 | 994 | restore_dir = 'testfiles/restore_out' | 1074 | restore_dir = 'testfiles/restore_out' |
247 | 995 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1075 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
248 | 996 | self.assertEqual(restored, []) | 1076 | self.assertEqual(restored, []) |
249 | 997 | @unittest.skipUnless(platform.platform().startswith('Linux'), | ||
250 | 998 | 'Skip on non-Linux systems') | ||
251 | 999 | 1077 | ||
252 | 1000 | def test_excludes_files_trailing_slash_globbing_chars(self): | 1078 | def test_excludes_files_trailing_slash_globbing_chars(self): |
253 | 1001 | """Tests folder excludes with globbing char and /""" | 1079 | """Tests folder excludes with globbing char and /""" |
254 | 1002 | 1080 | ||
255 | === modified file 'tox.ini' | |||
256 | --- tox.ini 2016-07-02 19:33:34 +0000 | |||
257 | +++ tox.ini 2017-01-15 22:30:30 +0000 | |||
258 | @@ -7,6 +7,7 @@ | |||
259 | 7 | deps= | 7 | deps= |
260 | 8 | mock | 8 | mock |
261 | 9 | pexpect | 9 | pexpect |
262 | 10 | jottalib | ||
263 | 10 | 11 | ||
264 | 11 | [testenv:lpbuildd-precise] | 12 | [testenv:lpbuildd-precise] |
265 | 12 | setenv= | 13 | setenv= |