diff options
| author | jvoisin | 2018-10-25 11:56:46 +0200 |
|---|---|---|
| committer | jvoisin | 2018-10-25 11:56:46 +0200 |
| commit | 3a070b0ab70c4d4a456bdd12d0cd490ad127e320 (patch) | |
| tree | 2a6e5a913136a49e9a70393fa030ea4eb67cbab0 /tests/test_corrupted_files.py | |
| parent | 283e5e57877b21e34eb4612d3201c2e0682190d5 (diff) | |
Add support for zip files
Diffstat (limited to 'tests/test_corrupted_files.py')
| -rw-r--r-- | tests/test_corrupted_files.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py index 181d4d2..e7d3c2a 100644 --- a/tests/test_corrupted_files.py +++ b/tests/test_corrupted_files.py | |||
| @@ -4,6 +4,7 @@ import unittest | |||
| 4 | import shutil | 4 | import shutil |
| 5 | import os | 5 | import os |
| 6 | import logging | 6 | import logging |
| 7 | import zipfile | ||
| 7 | 8 | ||
| 8 | from libmat2 import pdf, images, audio, office, parser_factory, torrent | 9 | from libmat2 import pdf, images, audio, office, parser_factory, torrent |
| 9 | from libmat2 import harmless, video | 10 | from libmat2 import harmless, video |
| @@ -222,3 +223,17 @@ class TestCorruptedFiles(unittest.TestCase): | |||
| 222 | p = video.AVIParser('./tests/data/--output.avi') | 223 | p = video.AVIParser('./tests/data/--output.avi') |
| 223 | self.assertFalse(p.remove_all()) | 224 | self.assertFalse(p.remove_all()) |
| 224 | os.remove('./tests/data/--output.avi') | 225 | os.remove('./tests/data/--output.avi') |
| 226 | |||
| 227 | def test_zip(self): | ||
| 228 | with zipfile.ZipFile('./tests/data/dirty.zip', 'w') as zout: | ||
| 229 | zout.write('./tests/data/dirty.flac') | ||
| 230 | zout.write('./tests/data/dirty.docx') | ||
| 231 | zout.write('./tests/data/dirty.jpg') | ||
| 232 | zout.write('./tests/data/embedded_corrupted.docx') | ||
| 233 | p, mimetype = parser_factory.get_parser('./tests/data/dirty.zip') | ||
| 234 | self.assertEqual(mimetype, 'application/zip') | ||
| 235 | meta = p.get_meta() | ||
| 236 | self.assertEqual(meta['tests/data/dirty.flac']['comments'], 'Thank you for using MAT !') | ||
| 237 | self.assertEqual(meta['tests/data/dirty.docx']['word/media/image1.png']['Comment'], 'This is a comment, be careful!') | ||
| 238 | self.assertFalse(p.remove_all()) | ||
| 239 | os.remove('./tests/data/dirty.zip') | ||
