duplicity-team team mailing list archive
-
duplicity-team team
-
Mailing list archive
-
Message #04080
[Merge] lp:~aaron-whitehouse/duplicity/0-8-merge_selection_tests into lp:duplicity
Aaron Whitehouse has proposed merging lp:~aaron-whitehouse/duplicity/0-8-merge_selection_tests into lp:duplicity.
Requested reviews:
duplicity-team (duplicity-team)
For more details, see:
https://code.launchpad.net/~aaron-whitehouse/duplicity/0-8-merge_selection_tests/+merge/314789
* 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.
--
Your team duplicity-team is requested to review the proposed merge of lp:~aaron-whitehouse/duplicity/0-8-merge_selection_tests into lp:duplicity.
=== 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 @@
authorization_url, _ = self.http_client.authorization_url(
self.OAUTH_AUTHORIZE_URL)
- print ''
- print ('In order to allow duplicity to access Amazon Drive, please '
- 'open the following URL in a browser and copy the URL of the '
- 'page you see after authorization here:')
- print authorization_url
- print ''
+ print('')
+ print('In order to allow duplicity to access Amazon Drive, please '
+ 'open the following URL in a browser and copy the URL of the '
+ 'page you see after authorization here:')
+ print(authorization_url)
+ print('')
redirected_to = (raw_input('URL of the resulting page: ')
.replace('http://', 'https://', 1)).strip()
=== 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 @@
import sys
import platform
-if sys.version_info < (2, 7):
- import unittest2 as unittest # @UnresolvedImport @UnusedImport
-else:
- import unittest # @Reimport
+import unittest
from . import FunctionalTestCase
@@ -842,6 +839,57 @@
self.restore_and_check()
+class TestTrailingSlash2(IncludeExcludeFunctionalTest):
+ """ This tests the behaviour of globbing strings with a trailing slash"""
+ # See Bug #1479545 (https://bugs.launchpad.net/duplicity/+bug/1479545)
+
+ def test_no_trailing_slash(self):
+ """ Test that including 1.py works as expected"""
+ self.backup("full", "testfiles/select2",
+ options=["--include", "testfiles/select2/1.py",
+ "--exclude", "**"])
+ self.restore()
+ restore_dir = 'testfiles/restore_out'
+ restored = self.directory_tree_to_list_of_lists(restore_dir)
+ self.assertEqual(restored, [['1.py']])
+
+ def test_trailing_slash(self):
+ """ Test that globs with a trailing slash only match directories"""
+ # Regression test for Bug #1479545
+ # (https://bugs.launchpad.net/duplicity/+bug/1479545)
+ self.backup("full", "testfiles/select2",
+ options=["--include", "testfiles/select2/1.py/",
+ "--exclude", "**"])
+ self.restore()
+ restore_dir = 'testfiles/restore_out'
+ restored = self.directory_tree_to_list_of_lists(restore_dir)
+ self.assertEqual(restored, [])
+
+ def test_include_files_not_subdirectories(self):
+ """ Test that a trailing slash glob followed by a * glob only matches
+ files and not subdirectories"""
+ self.backup("full", "testfiles/select2",
+ options=["--exclude", "testfiles/select2/*/",
+ "--include", "testfiles/select2/*",
+ "--exclude", "**"])
+ self.restore()
+ restore_dir = 'testfiles/restore_out'
+ restored = self.directory_tree_to_list_of_lists(restore_dir)
+ self.assertEqual(restored, [['1.doc', '1.py']])
+
+ def test_include_subdirectories_not_files(self):
+ """ Test that a trailing slash glob only matches directories"""
+ self.backup("full", "testfiles/select2",
+ options=["--include", "testfiles/select2/1/1sub1/**/",
+ "--exclude", "testfiles/select2/1/1sub1/**",
+ "--exclude", "**"])
+ self.restore()
+ restore_dir = 'testfiles/restore_out'
+ restored = self.directory_tree_to_list_of_lists(restore_dir)
+ self.assertEqual(restored, [['1'], ['1sub1'],
+ ['1sub1sub1', '1sub1sub2', '1sub1sub3']])
+
+
class TestGlobbingReplacement(IncludeExcludeFunctionalTest):
""" This tests the behaviour of the extended shell globbing pattern replacement functions."""
# See the manual for a description of behaviours, but in summary:
@@ -880,55 +928,89 @@
self.assertEqual(restored, self.expected_restored_tree)
-class TestTrailingSlash(IncludeExcludeFunctionalTest):
- """ This tests the behaviour of globbing strings with a trailing slash"""
- # See Bug #1479545 (https://bugs.launchpad.net/duplicity/+bug/1479545)
-
- def test_no_trailing_slash(self):
- """ Test that including 1.py works as expected"""
- self.backup("full", "testfiles/select2",
- options=["--include", "testfiles/select2/1.py",
- "--exclude", "**"])
- self.restore()
- restore_dir = 'testfiles/restore_out'
- restored = self.directory_tree_to_list_of_lists(restore_dir)
- self.assertEqual(restored, [['1.py']])
-
- def test_trailing_slash(self):
- """ Test that globs with a trailing slash only match directories"""
- # ToDo: Bug #1479545
- # (https://bugs.launchpad.net/duplicity/+bug/1479545)
- self.backup("full", "testfiles/select2",
- options=["--include", "testfiles/select2/1.py/",
- "--exclude", "**"])
- self.restore()
- restore_dir = 'testfiles/restore_out'
- restored = self.directory_tree_to_list_of_lists(restore_dir)
- self.assertEqual(restored, [])
-
- def test_include_files_not_subdirectories(self):
- """ Test that a trailing slash glob followed by a * glob only matches
- files and not subdirectories"""
- self.backup("full", "testfiles/select2",
- options=["--exclude", "testfiles/select2/*/",
- "--include", "testfiles/select2/*",
- "--exclude", "**"])
- self.restore()
- restore_dir = 'testfiles/restore_out'
- restored = self.directory_tree_to_list_of_lists(restore_dir)
- self.assertEqual(restored, [['1.doc', '1.py']])
-
- def test_include_subdirectories_not_files(self):
- """ Test that a trailing slash glob only matches directories"""
- self.backup("full", "testfiles/select2",
- options=["--include", "testfiles/select2/1/1sub1/**/",
- "--exclude", "testfiles/select2/1/1sub1/**",
- "--exclude", "**"])
- self.restore()
- restore_dir = 'testfiles/restore_out'
- restored = self.directory_tree_to_list_of_lists(restore_dir)
- self.assertEqual(restored, [['1'], ['1sub1'],
- ['1sub1sub1', '1sub1sub2', '1sub1sub3']])
+class TestExcludeIfPresent(IncludeExcludeFunctionalTest):
+ """ This tests the behaviour of duplicity's --exclude-if-present option"""
+
+ def test_exclude_if_present_baseline(self):
+ """ Test that duplicity normally backs up files"""
+ with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag:
+ tag.write("Files in this folder should not be backed up.")
+ self.backup("full", "testfiles/select2/1/1sub1",
+ options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
+ "--exclude", "**"])
+ self.restore()
+ restore_dir = 'testfiles/restore_out'
+ restored = self.directory_tree_to_list_of_lists(restore_dir)
+ self.assertEqual(restored, [['1sub1sub1'],
+ ['.nobackup', '1sub1sub1_file.txt']])
+
+ def test_exclude_if_present_excludes(self):
+ """ Test that duplicity excludes files with relevant tag"""
+ with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag:
+ tag.write("Files in this folder should not be backed up.")
+ self.backup("full", "testfiles/select2/1/1sub1",
+ options=["--exclude-if-present", ".nobackup",
+ "--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
+ "--exclude", "**"])
+ self.restore()
+ restore_dir = 'testfiles/restore_out'
+ restored = self.directory_tree_to_list_of_lists(restore_dir)
+ self.assertEqual(restored, [])
+
+ def test_exclude_if_present_excludes_2(self):
+ """ Test that duplicity excludes files with relevant tag"""
+ with open("testfiles/select2/1/1sub1/1sub1sub1/EXCLUDE.tag", "w") as tag:
+ tag.write("Files in this folder should also not be backed up.")
+ self.backup("full", "testfiles/select2/1/1sub1",
+ options=["--exclude-if-present", "EXCLUDE.tag",
+ "--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
+ "--exclude", "**"])
+ self.restore()
+ restore_dir = 'testfiles/restore_out'
+ restored = self.directory_tree_to_list_of_lists(restore_dir)
+ self.assertEqual(restored, [])
+
+
+class TestLockedFoldersNoError(IncludeExcludeFunctionalTest):
+ """ This tests that inaccessible folders do not cause an error"""
+
+ @unittest.skipUnless(platform.platform().startswith('Linux'),
+ 'Skip on non-Linux systems')
+ def test_locked_baseline(self):
+ """ Test no error if locked in path but excluded"""
+ folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3"
+ initial_mode = os.stat(folder_to_lock).st_mode
+ os.chmod(folder_to_lock, 0o0000)
+ self.backup("full", "testfiles/select2/1/1sub1",
+ options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
+ "--exclude", "**"])
+ os.chmod(folder_to_lock, initial_mode)
+ self.restore()
+ restore_dir = 'testfiles/restore_out'
+ restored = self.directory_tree_to_list_of_lists(restore_dir)
+ self.assertEqual(restored, [['1sub1sub1'],
+ ['1sub1sub1_file.txt']])
+
+ @unittest.skipUnless(platform.platform().startswith('Linux'),
+ 'Skip on non-Linux systems')
+ def test_locked_excl_if_present(self):
+ """ Test no error if excluded locked with --exclude-if-present"""
+ # Regression test for Bug #1620085
+ # https://bugs.launchpad.net/duplicity/+bug/1620085
+ folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3"
+ initial_mode = os.stat(folder_to_lock).st_mode
+ os.chmod(folder_to_lock, 0o0000)
+ self.backup("full", "testfiles/select2/1/1sub1",
+ options=["--exclude-if-present", "EXCLUDE.tag",
+ "--include", "testfiles/select2/1/1sub1/1sub1sub1/*",
+ "--exclude", "**"])
+ os.chmod(folder_to_lock, initial_mode)
+ self.restore()
+ restore_dir = 'testfiles/restore_out'
+ restored = self.directory_tree_to_list_of_lists(restore_dir)
+ self.assertEqual(restored, [['1sub1sub1'],
+ ['1sub1sub1_file.txt']])
+
class TestFolderIncludesFiles(IncludeExcludeFunctionalTest):
""" This tests that including a folder includes the files within it"""
@@ -980,8 +1062,6 @@
restored = self.directory_tree_to_list_of_lists(restore_dir)
self.assertEqual(restored, [])
- @unittest.skipUnless(platform.platform().startswith('Linux'),
- 'Skip on non-Linux systems')
def test_excludes_files_trailing_slash(self):
"""Excluding a folder excludes the files within it, if ends with /"""
self.backup("full", "testfiles/select2/1/1sub1",
@@ -994,8 +1074,6 @@
restore_dir = 'testfiles/restore_out'
restored = self.directory_tree_to_list_of_lists(restore_dir)
self.assertEqual(restored, [])
- @unittest.skipUnless(platform.platform().startswith('Linux'),
- 'Skip on non-Linux systems')
def test_excludes_files_trailing_slash_globbing_chars(self):
"""Tests folder excludes with globbing char and /"""
=== 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 @@
deps=
mock
pexpect
+ jottalib
[testenv:lpbuildd-precise]
setenv=
Follow ups