diff options
| author | jvoisin | 2014-01-06 11:24:07 +0000 |
|---|---|---|
| committer | jvoisin | 2014-01-06 11:24:07 +0000 |
| commit | 5d8f4b5c82f13e533248d88faefdd1cadebb1eb6 (patch) | |
| tree | bf6a3d1e0221d4abdef1d4d9eac23e879ba728f8 | |
| parent | 9708bafa709cf8c04579315baafd31f1a1365637 (diff) | |
Add a test got get_unsupported_archive
| -rw-r--r-- | MAT/archive.py | 3 | ||||
| -rw-r--r-- | test/libtest.py | 21 |
2 files changed, 20 insertions, 4 deletions
diff --git a/MAT/archive.py b/MAT/archive.py index 212e638..5b8d9a8 100644 --- a/MAT/archive.py +++ b/MAT/archive.py | |||
| @@ -224,7 +224,8 @@ class TarStripper(GenericArchiveStripper): | |||
| 224 | basename, ext = os.path.splitext(complete_name) | 224 | basename, ext = os.path.splitext(complete_name) |
| 225 | if ext not in parser.NOMETA: | 225 | if ext not in parser.NOMETA: |
| 226 | if list_unsupported: | 226 | if list_unsupported: |
| 227 | ret_list.append(complete_name) | 227 | tmp_len = len(self.tempdir) + 1 # trim the tempfile path |
| 228 | ret_list.append(complete_name[tmp_len:]) | ||
| 228 | else: | 229 | else: |
| 229 | return False | 230 | return False |
| 230 | tarin.close() | 231 | tarin.close() |
diff --git a/test/libtest.py b/test/libtest.py index e869381..a9ef383 100644 --- a/test/libtest.py +++ b/test/libtest.py | |||
| @@ -103,13 +103,14 @@ class TestSecureRemove(unittest.TestCase): | |||
| 103 | self.assertRaises(MAT.exceptions.UnableToRemoveFile, MAT.mat.secure_remove, '/NOTREMOVABLE') | 103 | self.assertRaises(MAT.exceptions.UnableToRemoveFile, MAT.mat.secure_remove, '/NOTREMOVABLE') |
| 104 | 104 | ||
| 105 | class TestArchiveProcessing(test.MATTest): | 105 | class TestArchiveProcessing(test.MATTest): |
| 106 | ''' Test archives cleaning | 106 | ''' Test archives processing |
| 107 | ''' | 107 | ''' |
| 108 | def test_remove_bz2(self): | 108 | def test_remove_bz2(self): |
| 109 | tarpath = os.path.join(self.tmpdir, "test.tar.bz2") | 109 | tarpath = os.path.join(self.tmpdir, "test.tar.bz2") |
| 110 | tar = tarfile.open(tarpath, "w:bz2") | 110 | tar = tarfile.open(tarpath, "w:bz2") |
| 111 | for _,dirty in self.file_list: | 111 | for clean,dirty in self.file_list: |
| 112 | tar.add(dirty) | 112 | tar.add(dirty) |
| 113 | tar.add(clean) | ||
| 113 | tar.close() | 114 | tar.close() |
| 114 | current_file = MAT.mat.create_class_file(tarpath, False, add2archive=False) | 115 | current_file = MAT.mat.create_class_file(tarpath, False, add2archive=False) |
| 115 | current_file.remove_all() | 116 | current_file.remove_all() |
| @@ -119,14 +120,28 @@ class TestArchiveProcessing(test.MATTest): | |||
| 119 | def test_remove_tar(self): | 120 | def test_remove_tar(self): |
| 120 | tarpath = os.path.join(self.tmpdir, "test.tar") | 121 | tarpath = os.path.join(self.tmpdir, "test.tar") |
| 121 | tar = tarfile.open(tarpath, "w") | 122 | tar = tarfile.open(tarpath, "w") |
| 122 | for _,dirty in self.file_list: | 123 | for clean,dirty in self.file_list: |
| 123 | tar.add(dirty) | 124 | tar.add(dirty) |
| 125 | tar.add(clean) | ||
| 124 | tar.close() | 126 | tar.close() |
| 125 | current_file = MAT.mat.create_class_file(tarpath, False, add2archive=False) | 127 | current_file = MAT.mat.create_class_file(tarpath, False, add2archive=False) |
| 126 | current_file.remove_all() | 128 | current_file.remove_all() |
| 127 | current_file = MAT.mat.create_class_file(tarpath, False, add2archive=False) | 129 | current_file = MAT.mat.create_class_file(tarpath, False, add2archive=False) |
| 128 | self.assertTrue(current_file.is_clean()) | 130 | self.assertTrue(current_file.is_clean()) |
| 129 | 131 | ||
| 132 | def test_get_unsupported(self): | ||
| 133 | tarpath = os.path.join(self.tmpdir, "test.tar.bz2") | ||
| 134 | tar = tarfile.open(tarpath, "w") | ||
| 135 | for clean,dirty in self.file_list[:4]: # we don't test thoses | ||
| 136 | tar.add(dirty) | ||
| 137 | tar.add(clean) | ||
| 138 | for f in ('../mat.desktop', '../README.security', '../setup.py'): | ||
| 139 | tar.add(f, f[3:]) # trim '../' | ||
| 140 | tar.close() | ||
| 141 | current_file = MAT.mat.create_class_file(tarpath, False, add2archive=False) | ||
| 142 | unsupported_files = set(current_file.is_clean(list_unsupported=True)) | ||
| 143 | self.assertEqual(unsupported_files, set(('mat.desktop', 'README.security', 'setup.py'))) | ||
| 144 | |||
| 130 | def get_tests(): | 145 | def get_tests(): |
| 131 | ''' Returns every libtests''' | 146 | ''' Returns every libtests''' |
| 132 | suite = unittest.TestSuite() | 147 | suite = unittest.TestSuite() |
