1
0
mirror of synced 2024-11-25 18:54:22 +01:00

Check that cleaning twice doesn't break the file

This commit is contained in:
jvoisin 2018-10-02 16:05:51 +02:00
parent 9578e4b4ee
commit 156e81fb4c

View File

@ -229,6 +229,7 @@ class TestCleaning(unittest.TestCase):
p = pdf.PDFParser('./tests/data/clean.cleaned.pdf') p = pdf.PDFParser('./tests/data/clean.cleaned.pdf')
expected_meta = {'creation-date': -1, 'format': 'PDF-1.5', 'mod-date': -1} expected_meta = {'creation-date': -1, 'format': 'PDF-1.5', 'mod-date': -1}
self.assertEqual(p.get_meta(), expected_meta) self.assertEqual(p.get_meta(), expected_meta)
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.pdf') os.remove('./tests/data/clean.pdf')
os.remove('./tests/data/clean.cleaned.pdf') os.remove('./tests/data/clean.cleaned.pdf')
@ -245,6 +246,7 @@ class TestCleaning(unittest.TestCase):
p = images.PNGParser('./tests/data/clean.cleaned.png') p = images.PNGParser('./tests/data/clean.cleaned.png')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.png') os.remove('./tests/data/clean.png')
os.remove('./tests/data/clean.cleaned.png') os.remove('./tests/data/clean.cleaned.png')
@ -261,6 +263,7 @@ class TestCleaning(unittest.TestCase):
p = images.JPGParser('./tests/data/clean.cleaned.jpg') p = images.JPGParser('./tests/data/clean.cleaned.jpg')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.jpg') os.remove('./tests/data/clean.jpg')
os.remove('./tests/data/clean.cleaned.jpg') os.remove('./tests/data/clean.cleaned.jpg')
@ -277,6 +280,7 @@ class TestCleaning(unittest.TestCase):
p = audio.MP3Parser('./tests/data/clean.cleaned.mp3') p = audio.MP3Parser('./tests/data/clean.cleaned.mp3')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.mp3') os.remove('./tests/data/clean.mp3')
os.remove('./tests/data/clean.cleaned.mp3') os.remove('./tests/data/clean.cleaned.mp3')
@ -293,6 +297,7 @@ class TestCleaning(unittest.TestCase):
p = audio.OGGParser('./tests/data/clean.cleaned.ogg') p = audio.OGGParser('./tests/data/clean.cleaned.ogg')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.ogg') os.remove('./tests/data/clean.ogg')
os.remove('./tests/data/clean.cleaned.ogg') os.remove('./tests/data/clean.cleaned.ogg')
@ -309,6 +314,7 @@ class TestCleaning(unittest.TestCase):
p = audio.FLACParser('./tests/data/clean.cleaned.flac') p = audio.FLACParser('./tests/data/clean.cleaned.flac')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.flac') os.remove('./tests/data/clean.flac')
os.remove('./tests/data/clean.cleaned.flac') os.remove('./tests/data/clean.cleaned.flac')
@ -325,6 +331,7 @@ class TestCleaning(unittest.TestCase):
p = office.MSOfficeParser('./tests/data/clean.cleaned.docx') p = office.MSOfficeParser('./tests/data/clean.cleaned.docx')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.docx') os.remove('./tests/data/clean.docx')
os.remove('./tests/data/clean.cleaned.docx') os.remove('./tests/data/clean.cleaned.docx')
@ -341,6 +348,7 @@ class TestCleaning(unittest.TestCase):
p = office.LibreOfficeParser('./tests/data/clean.cleaned.odt') p = office.LibreOfficeParser('./tests/data/clean.cleaned.odt')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.odt') os.remove('./tests/data/clean.odt')
os.remove('./tests/data/clean.cleaned.odt') os.remove('./tests/data/clean.cleaned.odt')
@ -357,6 +365,7 @@ class TestCleaning(unittest.TestCase):
p = images.TiffParser('./tests/data/clean.cleaned.tiff') p = images.TiffParser('./tests/data/clean.cleaned.tiff')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.tiff') os.remove('./tests/data/clean.tiff')
os.remove('./tests/data/clean.cleaned.tiff') os.remove('./tests/data/clean.cleaned.tiff')
@ -373,6 +382,7 @@ class TestCleaning(unittest.TestCase):
p = harmless.HarmlessParser('./tests/data/clean.cleaned.bmp') p = harmless.HarmlessParser('./tests/data/clean.cleaned.bmp')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.bmp') os.remove('./tests/data/clean.bmp')
os.remove('./tests/data/clean.cleaned.bmp') os.remove('./tests/data/clean.cleaned.bmp')
@ -389,6 +399,7 @@ class TestCleaning(unittest.TestCase):
p = torrent.TorrentParser('./tests/data/clean.cleaned.torrent') p = torrent.TorrentParser('./tests/data/clean.cleaned.torrent')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.torrent') os.remove('./tests/data/clean.torrent')
os.remove('./tests/data/clean.cleaned.torrent') os.remove('./tests/data/clean.cleaned.torrent')
@ -405,6 +416,7 @@ class TestCleaning(unittest.TestCase):
p = office.LibreOfficeParser('./tests/data/clean.cleaned.odf') p = office.LibreOfficeParser('./tests/data/clean.cleaned.odf')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.odf') os.remove('./tests/data/clean.odf')
os.remove('./tests/data/clean.cleaned.odf') os.remove('./tests/data/clean.cleaned.odf')
@ -421,6 +433,7 @@ class TestCleaning(unittest.TestCase):
p = office.LibreOfficeParser('./tests/data/clean.cleaned.odg') p = office.LibreOfficeParser('./tests/data/clean.cleaned.odg')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.odg') os.remove('./tests/data/clean.odg')
os.remove('./tests/data/clean.cleaned.odg') os.remove('./tests/data/clean.cleaned.odg')
@ -437,6 +450,7 @@ class TestCleaning(unittest.TestCase):
p = harmless.HarmlessParser('./tests/data/clean.cleaned.txt') p = harmless.HarmlessParser('./tests/data/clean.cleaned.txt')
self.assertEqual(p.get_meta(), {}) self.assertEqual(p.get_meta(), {})
self.assertTrue(p.remove_all())
os.remove('./tests/data/clean.txt') os.remove('./tests/data/clean.txt')
os.remove('./tests/data/clean.cleaned.txt') os.remove('./tests/data/clean.cleaned.txt')