diff options
| author | jvoisin | 2019-10-12 13:32:04 -0700 |
|---|---|---|
| committer | jvoisin | 2019-10-12 13:32:04 -0700 |
| commit | 3cef7fe7fc81c1495a461a8594b1df69467536ea (patch) | |
| tree | 2ddf7b8e181f7e606227dabdfc020fab4d4b4250 /tests/test_lightweigh_cleaning.py | |
| parent | 6d19a209355a7d1ef3bbee32ec7c9be93ed666ad (diff) | |
Refactor tests
Diffstat (limited to 'tests/test_lightweigh_cleaning.py')
| -rw-r--r-- | tests/test_lightweigh_cleaning.py | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/tests/test_lightweigh_cleaning.py b/tests/test_lightweigh_cleaning.py deleted file mode 100644 index a115f05..0000000 --- a/tests/test_lightweigh_cleaning.py +++ /dev/null | |||
| @@ -1,106 +0,0 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | |||
| 3 | import unittest | ||
| 4 | import shutil | ||
| 5 | import os | ||
| 6 | |||
| 7 | from libmat2 import pdf, images, torrent | ||
| 8 | |||
| 9 | class TestLightWeightCleaning(unittest.TestCase): | ||
| 10 | def test_pdf(self): | ||
| 11 | shutil.copy('./tests/data/dirty.pdf', './tests/data/clean.pdf') | ||
| 12 | p = pdf.PDFParser('./tests/data/clean.pdf') | ||
| 13 | |||
| 14 | meta = p.get_meta() | ||
| 15 | self.assertEqual(meta['producer'], 'pdfTeX-1.40.14') | ||
| 16 | |||
| 17 | p.lightweight_cleaning = True | ||
| 18 | ret = p.remove_all() | ||
| 19 | self.assertTrue(ret) | ||
| 20 | |||
| 21 | p = pdf.PDFParser('./tests/data/clean.cleaned.pdf') | ||
| 22 | expected_meta = {'creation-date': -1, 'format': 'PDF-1.5', 'mod-date': -1} | ||
| 23 | self.assertEqual(p.get_meta(), expected_meta) | ||
| 24 | |||
| 25 | os.remove('./tests/data/clean.pdf') | ||
| 26 | os.remove('./tests/data/clean.cleaned.pdf') | ||
| 27 | |||
| 28 | def test_png(self): | ||
| 29 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.png') | ||
| 30 | p = images.PNGParser('./tests/data/clean.png') | ||
| 31 | |||
| 32 | meta = p.get_meta() | ||
| 33 | self.assertEqual(meta['Comment'], 'This is a comment, be careful!') | ||
| 34 | |||
| 35 | p.lightweight_cleaning = True | ||
| 36 | ret = p.remove_all() | ||
| 37 | self.assertTrue(ret) | ||
| 38 | |||
| 39 | p = images.PNGParser('./tests/data/clean.cleaned.png') | ||
| 40 | self.assertEqual(p.get_meta(), {}) | ||
| 41 | |||
| 42 | p = images.PNGParser('./tests/data/clean.png') | ||
| 43 | p.lightweight_cleaning = True | ||
| 44 | ret = p.remove_all() | ||
| 45 | self.assertTrue(ret) | ||
| 46 | |||
| 47 | os.remove('./tests/data/clean.png') | ||
| 48 | os.remove('./tests/data/clean.cleaned.png') | ||
| 49 | |||
| 50 | def test_jpg(self): | ||
| 51 | shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') | ||
| 52 | p = images.JPGParser('./tests/data/clean.jpg') | ||
| 53 | |||
| 54 | meta = p.get_meta() | ||
| 55 | self.assertEqual(meta['Comment'], 'Created with GIMP') | ||
| 56 | |||
| 57 | p.lightweight_cleaning = True | ||
| 58 | ret = p.remove_all() | ||
| 59 | self.assertTrue(ret) | ||
| 60 | |||
| 61 | p = images.JPGParser('./tests/data/clean.cleaned.jpg') | ||
| 62 | self.assertEqual(p.get_meta(), {}) | ||
| 63 | |||
| 64 | os.remove('./tests/data/clean.jpg') | ||
| 65 | os.remove('./tests/data/clean.cleaned.jpg') | ||
| 66 | |||
| 67 | def test_torrent(self): | ||
| 68 | shutil.copy('./tests/data/dirty.torrent', './tests/data/clean.torrent') | ||
| 69 | p = torrent.TorrentParser('./tests/data/clean.torrent') | ||
| 70 | |||
| 71 | meta = p.get_meta() | ||
| 72 | self.assertEqual(meta['created by'], b'mktorrent 1.0') | ||
| 73 | |||
| 74 | p.lightweight_cleaning = True | ||
| 75 | ret = p.remove_all() | ||
| 76 | self.assertTrue(ret) | ||
| 77 | |||
| 78 | p = torrent.TorrentParser('./tests/data/clean.cleaned.torrent') | ||
| 79 | self.assertEqual(p.get_meta(), {}) | ||
| 80 | |||
| 81 | os.remove('./tests/data/clean.torrent') | ||
| 82 | os.remove('./tests/data/clean.cleaned.torrent') | ||
| 83 | |||
| 84 | def test_tiff(self): | ||
| 85 | shutil.copy('./tests/data/dirty.tiff', './tests/data/clean.tiff') | ||
| 86 | p = images.TiffParser('./tests/data/clean.tiff') | ||
| 87 | |||
| 88 | meta = p.get_meta() | ||
| 89 | self.assertEqual(meta['ImageDescription'], 'OLYMPUS DIGITAL CAMERA ') | ||
| 90 | |||
| 91 | p.lightweight_cleaning = True | ||
| 92 | ret = p.remove_all() | ||
| 93 | self.assertTrue(ret) | ||
| 94 | |||
| 95 | p = images.TiffParser('./tests/data/clean.cleaned.tiff') | ||
| 96 | self.assertEqual(p.get_meta(), | ||
| 97 | { | ||
| 98 | 'Orientation': 'Horizontal (normal)', | ||
| 99 | 'ResolutionUnit': 'inches', | ||
| 100 | 'XResolution': 72, | ||
| 101 | 'YResolution': 72 | ||
| 102 | } | ||
| 103 | ) | ||
| 104 | |||
| 105 | os.remove('./tests/data/clean.tiff') | ||
| 106 | os.remove('./tests/data/clean.cleaned.tiff') | ||
