Commit 9826de35 authored by jvoisin's avatar jvoisin

Add a test for zip ordering

parent ab71c29a
Pipeline #19070 failed with stages
in 3 minutes and 14 seconds
......@@ -70,3 +70,38 @@ class TestZipMetadata(unittest.TestCase):
os.remove('./tests/data/clean.odt')
os.remove('./tests/data/clean.cleaned.odt')
class TestZipOrder(unittest.TestCase):
def test_libreoffice(self):
shutil.copy('./tests/data/dirty.odt', './tests/data/clean.odt')
p = office.LibreOfficeParser('./tests/data/clean.odt')
meta = p.get_meta()
self.assertIsNotNone(meta)
is_unordered = False
with zipfile.ZipFile('./tests/data/clean.odt') as zin:
previous_name = ''
for item in zin.infolist():
if previous_name == '':
previous_name = item.filename
continue
elif item.filename < previous_name:
is_unordered = True
break
self.assertTrue(is_unordered)
ret = p.remove_all()
self.assertTrue(ret)
with zipfile.ZipFile('./tests/data/clean.cleaned.odt') as zin:
previous_name = ''
for item in zin.infolist():
if previous_name == '':
previous_name = item.filename
continue
self.assertGreaterEqual(item.filename, previous_name)
os.remove('./tests/data/clean.odt')
os.remove('./tests/data/clean.cleaned.odt')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment