diff options
| author | jvoisin | 2018-04-01 00:17:06 +0200 |
|---|---|---|
| committer | jvoisin | 2018-04-01 00:17:06 +0200 |
| commit | c186fc42929b2660e5c507adeb8a8fb406593b11 (patch) | |
| tree | c82d071d61ceec3a20d48961390e73f6139f2136 /tests | |
| parent | 6d506b87575ded3a59c9fc4f7b28d4160d9e9c43 (diff) | |
Clean deep metadata for zip files
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_libmat2.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index c065237..888c782 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -57,7 +57,7 @@ class TestGetMeta(unittest.TestCase): | |||
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | class TestDeepCleaning(unittest.TestCase): | 59 | class TestDeepCleaning(unittest.TestCase): |
| 60 | def __check_zip_clean(self, p): | 60 | def __check_deep_meta(self, p): |
| 61 | tempdir = tempfile.mkdtemp() | 61 | tempdir = tempfile.mkdtemp() |
| 62 | zipin = zipfile.ZipFile(p.filename) | 62 | zipin = zipfile.ZipFile(p.filename) |
| 63 | zipin.extractall(tempdir) | 63 | zipin.extractall(tempdir) |
| @@ -72,6 +72,15 @@ class TestDeepCleaning(unittest.TestCase): | |||
| 72 | self.assertEqual(inside_p.get_meta(), {}) | 72 | self.assertEqual(inside_p.get_meta(), {}) |
| 73 | shutil.rmtree(tempdir) | 73 | shutil.rmtree(tempdir) |
| 74 | 74 | ||
| 75 | |||
| 76 | def __check_zip_meta(self, p): | ||
| 77 | zipin = zipfile.ZipFile(p.filename) | ||
| 78 | for item in zipin.infolist(): | ||
| 79 | self.assertEqual(item.comment, b'') | ||
| 80 | self.assertEqual(item.date_time, (1980, 1, 1, 0, 0, 0)) | ||
| 81 | self.assertEqual(item.create_system, 3) # 3 is UNIX | ||
| 82 | |||
| 83 | |||
| 75 | def test_office(self): | 84 | def test_office(self): |
| 76 | shutil.copy('./tests/data/dirty.docx', './tests/data/clean.docx') | 85 | shutil.copy('./tests/data/dirty.docx', './tests/data/clean.docx') |
| 77 | p = office.OfficeParser('./tests/data/clean.docx') | 86 | p = office.OfficeParser('./tests/data/clean.docx') |
| @@ -85,7 +94,8 @@ class TestDeepCleaning(unittest.TestCase): | |||
| 85 | p = office.OfficeParser('./tests/data/clean.docx.cleaned') | 94 | p = office.OfficeParser('./tests/data/clean.docx.cleaned') |
| 86 | self.assertEqual(p.get_meta(), {}) | 95 | self.assertEqual(p.get_meta(), {}) |
| 87 | 96 | ||
| 88 | self.__check_zip_clean(p) | 97 | self.__check_zip_meta(p) |
| 98 | self.__check_deep_meta(p) | ||
| 89 | 99 | ||
| 90 | os.remove('./tests/data/clean.docx') | 100 | os.remove('./tests/data/clean.docx') |
| 91 | 101 | ||
| @@ -103,7 +113,8 @@ class TestDeepCleaning(unittest.TestCase): | |||
| 103 | p = libreoffice.LibreOfficeParser('./tests/data/clean.odt.cleaned') | 113 | p = libreoffice.LibreOfficeParser('./tests/data/clean.odt.cleaned') |
| 104 | self.assertEqual(p.get_meta(), {}) | 114 | self.assertEqual(p.get_meta(), {}) |
| 105 | 115 | ||
| 106 | self.__check_zip_clean(p) | 116 | self.__check_zip_meta(p) |
| 117 | self.__check_deep_meta(p) | ||
| 107 | 118 | ||
| 108 | os.remove('./tests/data/clean.odt') | 119 | os.remove('./tests/data/clean.odt') |
| 109 | 120 | ||
