diff options
| author | jvoisin | 2018-10-01 22:26:35 +0200 |
|---|---|---|
| committer | jvoisin | 2018-10-02 11:55:42 -0700 |
| commit | c67bbafb2c60782096af4f6225d94e18225d2ecf (patch) | |
| tree | 0cef3d44437aa436be0446d2231f53b3776735bf /tests/test_corrupted_files.py | |
| parent | 5b606f939d7fb49830ab765585ca997bd44cfd76 (diff) | |
Use [Content_Types].xml to improve MS Office coverage
Diffstat (limited to 'tests/test_corrupted_files.py')
| -rw-r--r-- | tests/test_corrupted_files.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py index 4ac2678..8d7c252 100644 --- a/tests/test_corrupted_files.py +++ b/tests/test_corrupted_files.py | |||
| @@ -86,14 +86,26 @@ class TestExplicitelyUnsupportedFiles(unittest.TestCase): | |||
| 86 | os.remove('./tests/data/clean.py') | 86 | os.remove('./tests/data/clean.py') |
| 87 | 87 | ||
| 88 | 88 | ||
| 89 | class TestCorruptedContentTypesOffice(unittest.TestCase): | 89 | class TestWrongContentTypesFileOffice(unittest.TestCase): |
| 90 | def test_office(self): | 90 | def test_office_incomplete(self): |
| 91 | shutil.copy('./tests/data/malformed_content_types.docx', './tests/data/clean.docx') | 91 | shutil.copy('./tests/data/malformed_content_types.docx', './tests/data/clean.docx') |
| 92 | p = office.MSOfficeParser('./tests/data/clean.docx') | 92 | p = office.MSOfficeParser('./tests/data/clean.docx') |
| 93 | self.assertIsNotNone(p) | 93 | self.assertIsNotNone(p) |
| 94 | self.assertFalse(p.remove_all()) | 94 | self.assertFalse(p.remove_all()) |
| 95 | os.remove('./tests/data/clean.docx') | 95 | os.remove('./tests/data/clean.docx') |
| 96 | 96 | ||
| 97 | def test_office_broken(self): | ||
| 98 | shutil.copy('./tests/data/broken_xml_content_types.docx', './tests/data/clean.docx') | ||
| 99 | with self.assertRaises(ValueError): | ||
| 100 | office.MSOfficeParser('./tests/data/clean.docx') | ||
| 101 | os.remove('./tests/data/clean.docx') | ||
| 102 | |||
| 103 | def test_office_absent(self): | ||
| 104 | shutil.copy('./tests/data/no_content_types.docx', './tests/data/clean.docx') | ||
| 105 | with self.assertRaises(ValueError): | ||
| 106 | office.MSOfficeParser('./tests/data/clean.docx') | ||
| 107 | os.remove('./tests/data/clean.docx') | ||
| 108 | |||
| 97 | class TestCorruptedFiles(unittest.TestCase): | 109 | class TestCorruptedFiles(unittest.TestCase): |
| 98 | def test_pdf(self): | 110 | def test_pdf(self): |
| 99 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.png') | 111 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.png') |
