summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Marchant2024-04-03 15:03:33 -0400
committerAlex Marchant2024-04-03 15:03:33 -0400
commit1b9ce34e2c3da718e79137e2c2210ccdcd299486 (patch)
treed780ad1350206b36839896201777d67bb3f05190
parent17e76ab6f0f2f3ffdf0c2c2a09f37378de69e740 (diff)
Add test that checks if comments.xml is removed without errors
Diffstat (limited to '')
-rw-r--r--tests/data/comment.docxbin0 -> 17085 bytes
-rw-r--r--tests/test_libmat2.py17
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/data/comment.docx b/tests/data/comment.docx
new file mode 100644
index 0000000..c25485f
--- /dev/null
+++ b/tests/data/comment.docx
Binary files differ
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index c64e4cb..32ae543 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -858,3 +858,20 @@ class TestComplexOfficeFiles(unittest.TestCase):
858 858
859 os.remove(target) 859 os.remove(target)
860 os.remove(p.output_filename) 860 os.remove(p.output_filename)
861
862class TextDocx(unittest.TestCase):
863 def test_comment_xml_is_removed(self):
864 with zipfile.ZipFile('./tests/data/comment.docx') as zipin:
865 # Check if 'word/comments.xml' exists in the zip
866 self.assertIn('word/comments.xml', zipin.namelist())
867
868 shutil.copy('./tests/data/comment.docx', './tests/data/comment_clean.docx')
869 p = office.MSOfficeParser('./tests/data/comment_clean.docx')
870 self.assertTrue(p.remove_all())
871
872 with zipfile.ZipFile('./tests/data/comment_clean.cleaned.docx') as zipin:
873 # Check if 'word/comments.xml' exists in the zip
874 self.assertNotIn('word/comments.xml', zipin.namelist())
875
876 os.remove('./tests/data/comment_clean.docx')
877 os.remove('./tests/data/comment_clean.cleaned.docx') \ No newline at end of file