|
@@ -106,22 +106,24 @@ class ArchiverTestCaseBase(AtticTestCase):
|
|
|
|
|
|
class ArchiverTestCase(ArchiverTestCaseBase):
|
|
|
|
|
|
- def create_regual_file(self, name, size=0):
|
|
|
+ def create_regular_file(self, name, size=0, contents=None):
|
|
|
filename = os.path.join(self.input_path, name)
|
|
|
if not os.path.exists(os.path.dirname(filename)):
|
|
|
os.makedirs(os.path.dirname(filename))
|
|
|
with open(filename, 'wb') as fd:
|
|
|
- fd.write(b'X' * size)
|
|
|
+ if contents is None:
|
|
|
+ contents = b'X' * size
|
|
|
+ fd.write(contents)
|
|
|
|
|
|
def create_test_files(self):
|
|
|
"""Create a minimal test case including all supported file types
|
|
|
"""
|
|
|
# File
|
|
|
- self.create_regual_file('empty', size=0)
|
|
|
- self.create_regual_file('file1', size=1024 * 80)
|
|
|
- self.create_regual_file('flagfile', size=1024)
|
|
|
+ self.create_regular_file('empty', size=0)
|
|
|
+ self.create_regular_file('file1', size=1024 * 80)
|
|
|
+ self.create_regular_file('flagfile', size=1024)
|
|
|
# Directory
|
|
|
- self.create_regual_file('dir2/file2', size=1024 * 80)
|
|
|
+ self.create_regular_file('dir2/file2', size=1024 * 80)
|
|
|
# File owner
|
|
|
os.chown('input/file1', 100, 200)
|
|
|
# File mode
|
|
@@ -163,10 +165,10 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|
|
|
|
|
def test_extract_include_exclude(self):
|
|
|
self.attic('init', self.repository_location)
|
|
|
- self.create_regual_file('file1', size=1024 * 80)
|
|
|
- self.create_regual_file('file2', size=1024 * 80)
|
|
|
- self.create_regual_file('file3', size=1024 * 80)
|
|
|
- self.create_regual_file('file4', size=1024 * 80)
|
|
|
+ self.create_regular_file('file1', size=1024 * 80)
|
|
|
+ self.create_regular_file('file2', size=1024 * 80)
|
|
|
+ self.create_regular_file('file3', size=1024 * 80)
|
|
|
+ self.create_regular_file('file4', size=1024 * 80)
|
|
|
self.attic('create', '--exclude=input/file4', self.repository_location + '::test', 'input')
|
|
|
with changedir('output'):
|
|
|
self.attic('extract', self.repository_location + '::test', 'input/file1', )
|
|
@@ -178,9 +180,20 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|
|
self.attic('extract', '--exclude-from=' + self.exclude_file_path, self.repository_location + '::test')
|
|
|
self.assert_equal(sorted(os.listdir('output/input')), ['file1', 'file3'])
|
|
|
|
|
|
+ def test_exclude_caches(self):
|
|
|
+ self.attic('init', self.repository_location)
|
|
|
+ self.create_regular_file('file1', size=1024 * 80)
|
|
|
+ self.create_regular_file('cache1/CACHEDIR.TAG', contents = b'Signature: 8a477f597d28d172789f06886806bc55 extra stuff')
|
|
|
+ self.create_regular_file('cache2/CACHEDIR.TAG', contents = b'invalid signature')
|
|
|
+ self.attic('create', '--exclude-caches', self.repository_location + '::test', 'input')
|
|
|
+ with changedir('output'):
|
|
|
+ self.attic('extract', self.repository_location + '::test')
|
|
|
+ self.assert_equal(sorted(os.listdir('output/input')), ['cache2', 'file1'])
|
|
|
+ self.assert_equal(sorted(os.listdir('output/input/cache2')), ['CACHEDIR.TAG'])
|
|
|
+
|
|
|
def test_path_normalization(self):
|
|
|
self.attic('init', self.repository_location)
|
|
|
- self.create_regual_file('dir1/dir2/file', size=1024 * 80)
|
|
|
+ self.create_regular_file('dir1/dir2/file', size=1024 * 80)
|
|
|
with changedir('input/dir1/dir2'):
|
|
|
self.attic('create', self.repository_location + '::test', '../../../input/dir1/../dir1/dir2/..')
|
|
|
output = self.attic('list', self.repository_location + '::test')
|
|
@@ -188,13 +201,13 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|
|
self.assert_in(' input/dir1/dir2/file', output)
|
|
|
|
|
|
def test_repeated_files(self):
|
|
|
- self.create_regual_file('file1', size=1024 * 80)
|
|
|
+ self.create_regular_file('file1', size=1024 * 80)
|
|
|
self.attic('init', self.repository_location)
|
|
|
self.attic('create', self.repository_location + '::test', 'input', 'input')
|
|
|
|
|
|
def test_overwrite(self):
|
|
|
- self.create_regual_file('file1', size=1024 * 80)
|
|
|
- self.create_regual_file('dir2/file2', size=1024 * 80)
|
|
|
+ self.create_regular_file('file1', size=1024 * 80)
|
|
|
+ self.create_regular_file('dir2/file2', size=1024 * 80)
|
|
|
self.attic('init', self.repository_location)
|
|
|
self.attic('create', self.repository_location + '::test', 'input')
|
|
|
# Overwriting regular files and directories should be supported
|
|
@@ -212,8 +225,8 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|
|
self.attic('extract', self.repository_location + '::test', exit_code=1)
|
|
|
|
|
|
def test_delete(self):
|
|
|
- self.create_regual_file('file1', size=1024 * 80)
|
|
|
- self.create_regual_file('dir2/file2', size=1024 * 80)
|
|
|
+ self.create_regular_file('file1', size=1024 * 80)
|
|
|
+ self.create_regular_file('dir2/file2', size=1024 * 80)
|
|
|
self.attic('init', self.repository_location)
|
|
|
self.attic('create', self.repository_location + '::test', 'input')
|
|
|
self.attic('create', self.repository_location + '::test.2', 'input')
|
|
@@ -249,7 +262,7 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|
|
os.system('chmod -R u+w ' + self.repository_path)
|
|
|
|
|
|
def test_cmdline_compatibility(self):
|
|
|
- self.create_regual_file('file1', size=1024 * 80)
|
|
|
+ self.create_regular_file('file1', size=1024 * 80)
|
|
|
self.attic('init', self.repository_location)
|
|
|
self.attic('create', self.repository_location + '::test', 'input')
|
|
|
output = self.attic('verify', '-v', self.repository_location + '::test')
|