diff options
Diffstat (limited to 'tests/test_deep_cleaning.py')
| -rw-r--r-- | tests/test_deep_cleaning.py | 31 |
1 files changed, 31 insertions, 0 deletions
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 | |||
| 109 | class 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 | |||
