summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/office_revision_session_ids.docxbin0 -> 12163 bytes
-rw-r--r--tests/test_deep_cleaning.py31
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/data/office_revision_session_ids.docx b/tests/data/office_revision_session_ids.docx
new file mode 100644
index 0000000..b40a341
--- /dev/null
+++ b/tests/data/office_revision_session_ids.docx
Binary files differ
diff --git a/tests/test_deep_cleaning.py b/tests/test_deep_cleaning.py
index 3d1c8e1..82579a3 100644
--- a/tests/test_deep_cleaning.py
+++ b/tests/test_deep_cleaning.py
@@ -105,3 +105,34 @@ class TestZipOrder(unittest.TestCase):
105 105
106 os.remove('./tests/data/clean.odt') 106 os.remove('./tests/data/clean.odt')
107 os.remove('./tests/data/clean.cleaned.odt') 107 os.remove('./tests/data/clean.cleaned.odt')
108
109class TestRsidRemoval(unittest.TestCase):
110 def test_office(self):
111 shutil.copy('./tests/data/office_revision_session_ids.docx', './tests/data/clean.docx')
112 p = office.MSOfficeParser('./tests/data/clean.docx')
113
114 meta = p.get_meta()
115 self.assertIsNotNone(meta)
116
117 how_many_rsid = False
118 with zipfile.ZipFile('./tests/data/clean.docx') as zin:
119 for item in zin.infolist():
120 if not item.filename.endswith('.xml'):
121 continue
122 num = zin.read(item).decode('utf-8').lower().count('w:rsid')
123 how_many_rsid += num
124 self.assertEqual(how_many_rsid, 11)
125
126 ret = p.remove_all()
127 self.assertTrue(ret)
128
129 with zipfile.ZipFile('./tests/data/clean.cleaned.docx') as zin:
130 for item in zin.infolist():
131 if not item.filename.endswith('.xml'):
132 continue
133 num = zin.read(item).decode('utf-8').lower().count('w:rsid')
134 self.assertEqual(num, 0)
135
136 os.remove('./tests/data/clean.docx')
137 os.remove('./tests/data/clean.cleaned.docx')
138