From c67bbafb2c60782096af4f6225d94e18225d2ecf Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 1 Oct 2018 22:26:35 +0200 Subject: Use [Content_Types].xml to improve MS Office coverage --- tests/test_corrupted_files.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tests/test_corrupted_files.py') 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): os.remove('./tests/data/clean.py') -class TestCorruptedContentTypesOffice(unittest.TestCase): - def test_office(self): +class TestWrongContentTypesFileOffice(unittest.TestCase): + def test_office_incomplete(self): shutil.copy('./tests/data/malformed_content_types.docx', './tests/data/clean.docx') p = office.MSOfficeParser('./tests/data/clean.docx') self.assertIsNotNone(p) self.assertFalse(p.remove_all()) os.remove('./tests/data/clean.docx') + def test_office_broken(self): + shutil.copy('./tests/data/broken_xml_content_types.docx', './tests/data/clean.docx') + with self.assertRaises(ValueError): + office.MSOfficeParser('./tests/data/clean.docx') + os.remove('./tests/data/clean.docx') + + def test_office_absent(self): + shutil.copy('./tests/data/no_content_types.docx', './tests/data/clean.docx') + with self.assertRaises(ValueError): + office.MSOfficeParser('./tests/data/clean.docx') + os.remove('./tests/data/clean.docx') + class TestCorruptedFiles(unittest.TestCase): def test_pdf(self): shutil.copy('./tests/data/dirty.png', './tests/data/clean.png') -- cgit v1.3