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
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 authorization_url, _ = self.http_client.authorization_url(
6 self.OAUTH_AUTHORIZE_URL)
7
8- print ''
9- print ('In order to allow duplicity to access Amazon Drive, please '
10- 'open the following URL in a browser and copy the URL of the '
11- 'page you see after authorization here:')
12- print authorization_url
13- print ''
14+ print('')
15+ print('In order to allow duplicity to access Amazon Drive, please '
16+ 'open the following URL in a browser and copy the URL of the '
17+ 'page you see after authorization here:')
18+ print(authorization_url)
19+ print('')
20
21 redirected_to = (raw_input('URL of the resulting page: ')
22 .replace('http://', 'https://', 1)).strip()
23
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 import sys
29 import platform
30
31-if sys.version_info < (2, 7):
32- import unittest2 as unittest # @UnresolvedImport @UnusedImport
33-else:
34- import unittest # @Reimport
35+import unittest
36
37 from . import FunctionalTestCase
38
39@@ -842,6 +839,57 @@
40 self.restore_and_check()
41
42
43+class TestTrailingSlash2(IncludeExcludeFunctionalTest):
44+ """ This tests the behaviour of globbing strings with a trailing slash"""
45+ # See Bug #1479545 (https://bugs.launchpad.net/duplicity/+bug/1479545)
46+
47+ def test_no_trailing_slash(self):
48+ """ Test that including 1.py works as expected"""
49+ self.backup("full", "testfiles/select2",
50+ options=["--include", "testfiles/select2/1.py",
51+ "--exclude", "**"])
52+ self.restore()
53+ restore_dir = 'testfiles/restore_out'
54+ restored = self.directory_tree_to_list_of_lists(restore_dir)
55+ self.assertEqual(restored, [['1.py']])
56+
57+ def test_trailing_slash(self):
58+ """ Test that globs with a trailing slash only match directories"""
59+ # Regression test for Bug #1479545
60+ # (https://bugs.launchpad.net/duplicity/+bug/1479545)
61+ self.backup("full", "testfiles/select2",
62+ options=["--include", "testfiles/select2/1.py/",
63+ "--exclude", "**"])
64+ self.restore()
65+ restore_dir = 'testfiles/restore_out'
66+ restored = self.directory_tree_to_list_of_lists(restore_dir)
67+ self.assertEqual(restored, [])
68+
69+ def test_include_files_not_subdirectories(self):
70+ """ Test that a trailing slash glob followed by a * glob only matches
71+ files and not subdirectories"""
72+ self.backup("full", "testfiles/select2",
73+ options=["--exclude", "testfiles/select2/*/",
74+ "--include", "testfiles/select2/*",
75+ "--exclude", "**"])
76+ self.restore()
77+ restore_dir = 'testfiles/restore_out'
78+ restored = self.directory_tree_to_list_of_lists(restore_dir)
79+ self.assertEqual(restored, [['1.doc', '1.py']])
80+
81+ def test_include_subdirectories_not_files(self):
82+ """ Test that a trailing slash glob only matches directories"""
83+ self.backup("full", "testfiles/select2",
84+ options=["--include", "testfiles/select2/1/1sub1/**/",
85+ "--exclude", "testfiles/select2/1/1sub1/**",
86+ "--exclude", "**"])
87+ self.restore()
88+ restore_dir = 'testfiles/restore_out'
89+ restored = self.directory_tree_to_list_of_lists(restore_dir)
90+ self.assertEqual(restored, [['1'], ['1sub1'],
91+ ['1sub1sub1', '1sub1sub2', '1sub1sub3']])
92+
93+
94 class TestGlobbingReplacement(IncludeExcludeFunctionalTest):
95 """ This tests the behaviour of the extended shell globbing pattern replacement functions."""
96 # See the manual for a description of behaviours, but in summary:
97@@ -880,55 +928,89 @@
98 self.assertEqual(restored, self.expected_restored_tree)
99
100
101-class TestTrailingSlash(IncludeExcludeFunctionalTest):
102- """ This tests the behaviour of globbing strings with a trailing slash"""
103- # See Bug #1479545 (https://bugs.launchpad.net/duplicity/+bug/1479545)
104-
105- def test_no_trailing_slash(self):
106- """ Test that including 1.py works as expected"""
107- self.backup("full", "testfiles/select2",
108- options=["--include", "testfiles/select2/1.py",
109- "--exclude", "**"])
110- self.restore()
111- restore_dir = 'testfiles/restore_out'
112- restored = self.directory_tree_to_list_of_lists(restore_dir)
113- self.assertEqual(restored, [['1.py']])
114-
115- def test_trailing_slash(self):
116- """ Test that globs with a trailing slash only match directories"""
117- # ToDo: Bug #1479545
118- # (https://bugs.launchpad.net/duplicity/+bug/1479545)
119- self.backup("full", "testfiles/select2",
120- options=["--include", "testfiles/select2/1.py/",
121- "--exclude", "**"])
122- self.restore()
123- restore_dir = 'testfiles/restore_out'
124- restored = self.directory_tree_to_list_of_lists(restore_dir)
125- self.assertEqual(restored, [])
126-
127- def test_include_files_not_subdirectories(self):
128- """ Test that a trailing slash glob followed by a * glob only matches
129- files and not subdirectories"""
130- self.backup("full", "testfiles/select2",
131- options=["--exclude", "testfiles/select2/*/",
132- "--include", "testfiles/select2/*",
133- "--exclude", "**"])
134- self.restore()
135- restore_dir = 'testfiles/restore_out'
136- restored = self.directory_tree_to_list_of_lists(restore_dir)
137- self.assertEqual(restored, [['1.doc', '1.py']])
138-
139- def test_include_subdirectories_not_files(self):
140- """ Test that a trailing slash glob only matches directories"""
141- self.backup("full", "testfiles/select2",
142- options=["--include", "testfiles/select2/1/1sub1/**/",
143- "--exclude", "testfiles/select2/1/1sub1/**",
144- "--exclude", "**"])
145- self.restore()
146- restore_dir = 'testfiles/restore_out'
147- restored = self.directory_tree_to_list_of_lists(restore_dir)
148- self.assertEqual(restored, [['1'], ['1sub1'],
149- ['1sub1sub1', '1sub1sub2', '1sub1sub3']])
150+class TestExcludeIfPresent(IncludeExcludeFunctionalTest):
151+ """ This tests the behaviour of duplicity's --exclude-if-present option"""
152+
153+ def test_exclude_if_present_baseline(self):
154+ """ Test that duplicity normally backs up files"""
155+ with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag:
156+ tag.write("Files in this folder should not be backed up.")
157+ self.backup("full", "testfiles/select2/1/1sub1",
158+ options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
159+ "--exclude", "**"])
160+ self.restore()
161+ restore_dir = 'testfiles/restore_out'
162+ restored = self.directory_tree_to_list_of_lists(restore_dir)
163+ self.assertEqual(restored, [['1sub1sub1'],
164+ ['.nobackup', '1sub1sub1_file.txt']])
165+
166+ def test_exclude_if_present_excludes(self):
167+ """ Test that duplicity excludes files with relevant tag"""
168+ with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag:
169+ tag.write("Files in this folder should not be backed up.")
170+ self.backup("full", "testfiles/select2/1/1sub1",
171+ options=["--exclude-if-present", ".nobackup",
172+ "--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
173+ "--exclude", "**"])
174+ self.restore()
175+ restore_dir = 'testfiles/restore_out'
176+ restored = self.directory_tree_to_list_of_lists(restore_dir)
177+ self.assertEqual(restored, [])
178+
179+ def test_exclude_if_present_excludes_2(self):
180+ """ Test that duplicity excludes files with relevant tag"""
181+ with open("testfiles/select2/1/1sub1/1sub1sub1/EXCLUDE.tag", "w") as tag:
182+ tag.write("Files in this folder should also not be backed up.")
183+ self.backup("full", "testfiles/select2/1/1sub1",
184+ options=["--exclude-if-present", "EXCLUDE.tag",
185+ "--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
186+ "--exclude", "**"])
187+ self.restore()
188+ restore_dir = 'testfiles/restore_out'
189+ restored = self.directory_tree_to_list_of_lists(restore_dir)
190+ self.assertEqual(restored, [])
191+
192+
193+class TestLockedFoldersNoError(IncludeExcludeFunctionalTest):
194+ """ This tests that inaccessible folders do not cause an error"""
195+
196+ @unittest.skipUnless(platform.platform().startswith('Linux'),
197+ 'Skip on non-Linux systems')
198+ def test_locked_baseline(self):
199+ """ Test no error if locked in path but excluded"""
200+ folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3"
201+ initial_mode = os.stat(folder_to_lock).st_mode
202+ os.chmod(folder_to_lock, 0o0000)
203+ self.backup("full", "testfiles/select2/1/1sub1",
204+ options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
205+ "--exclude", "**"])
206+ os.chmod(folder_to_lock, initial_mode)
207+ self.restore()
208+ restore_dir = 'testfiles/restore_out'
209+ restored = self.directory_tree_to_list_of_lists(restore_dir)
210+ self.assertEqual(restored, [['1sub1sub1'],
211+ ['1sub1sub1_file.txt']])
212+
213+ @unittest.skipUnless(platform.platform().startswith('Linux'),
214+ 'Skip on non-Linux systems')
215+ def test_locked_excl_if_present(self):
216+ """ Test no error if excluded locked with --exclude-if-present"""
217+ # Regression test for Bug #1620085
218+ # https://bugs.launchpad.net/duplicity/+bug/1620085
219+ folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3"
220+ initial_mode = os.stat(folder_to_lock).st_mode
221+ os.chmod(folder_to_lock, 0o0000)
222+ self.backup("full", "testfiles/select2/1/1sub1",
223+ options=["--exclude-if-present", "EXCLUDE.tag",
224+ "--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
225+ "--exclude", "**"])
226+ os.chmod(folder_to_lock, initial_mode)
227+ self.restore()
228+ restore_dir = 'testfiles/restore_out'
229+ restored = self.directory_tree_to_list_of_lists(restore_dir)
230+ self.assertEqual(restored, [['1sub1sub1'],
231+ ['1sub1sub1_file.txt']])
232+
233
234 class TestFolderIncludesFiles(IncludeExcludeFunctionalTest):
235 """ This tests that including a folder includes the files within it"""
236@@ -980,8 +1062,6 @@
237 restored = self.directory_tree_to_list_of_lists(restore_dir)
238 self.assertEqual(restored, [])
239
240- @unittest.skipUnless(platform.platform().startswith('Linux'),
241- 'Skip on non-Linux systems')
242 def test_excludes_files_trailing_slash(self):
243 """Excluding a folder excludes the files within it, if ends with /"""
244 self.backup("full", "testfiles/select2/1/1sub1",
245@@ -994,8 +1074,6 @@
246 restore_dir = 'testfiles/restore_out'
247 restored = self.directory_tree_to_list_of_lists(restore_dir)
248 self.assertEqual(restored, [])
249- @unittest.skipUnless(platform.platform().startswith('Linux'),
250- 'Skip on non-Linux systems')
251
252 def test_excludes_files_trailing_slash_globbing_chars(self):
253 """Tests folder excludes with globbing char and /"""
254
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 deps=
260 mock
261 pexpect
262+ jottalib
263
264 [testenv:lpbuildd-precise]
265 setenv=

Subscribers

People subscribed via source and target branches