diff options
| author | jvoisin | 2018-03-25 15:09:12 +0200 |
|---|---|---|
| committer | jvoisin | 2018-03-25 15:09:12 +0200 |
| commit | d4d6f31655fb578825dbf1e639f165c7ad3eb17f (patch) | |
| tree | 65a5a64e2d0cf9dab964785efb1c50ce2af5eae0 /tests | |
| parent | 7ad9ff08ad52d16b05e689ef383e395b7731d594 (diff) | |
Add support for jpeg
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/data/dirty.jpg | bin | 0 -> 139309 bytes | |||
| -rw-r--r-- | tests/test_libmat2.py | 23 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/data/dirty.jpg b/tests/data/dirty.jpg new file mode 100644 index 0000000..15ca271 --- /dev/null +++ b/tests/data/dirty.jpg | |||
| Binary files differ | |||
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 9305080..1d31695 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -5,7 +5,7 @@ import shutil | |||
| 5 | import os | 5 | import os |
| 6 | 6 | ||
| 7 | from src import parsers | 7 | from src import parsers |
| 8 | from src.parsers import pdf, png | 8 | from src.parsers import pdf, png, jpg |
| 9 | 9 | ||
| 10 | class TestGetMeta(unittest.TestCase): | 10 | class TestGetMeta(unittest.TestCase): |
| 11 | def test_pdf(self): | 11 | def test_pdf(self): |
| @@ -20,6 +20,11 @@ class TestGetMeta(unittest.TestCase): | |||
| 20 | self.assertEqual(meta['Comment'], 'This is a comment, be careful!') | 20 | self.assertEqual(meta['Comment'], 'This is a comment, be careful!') |
| 21 | self.assertEqual(meta['ModifyDate'], "2018:03:20 21:59:25") | 21 | self.assertEqual(meta['ModifyDate'], "2018:03:20 21:59:25") |
| 22 | 22 | ||
| 23 | def test_jpg(self): | ||
| 24 | p = jpg.JPGParser('./tests/data/dirty.jpg') | ||
| 25 | meta = p.get_meta() | ||
| 26 | self.assertEqual(meta['Comment'], 'Created with GIMP') | ||
| 27 | |||
| 23 | class TestCleaning(unittest.TestCase): | 28 | class TestCleaning(unittest.TestCase): |
| 24 | def test_pdf(self): | 29 | def test_pdf(self): |
| 25 | shutil.copy('./tests/data/dirty.pdf', './tests/data/clean.pdf') | 30 | shutil.copy('./tests/data/dirty.pdf', './tests/data/clean.pdf') |
| @@ -51,3 +56,19 @@ class TestCleaning(unittest.TestCase): | |||
| 51 | self.assertEqual(p.get_meta(), {}) | 56 | self.assertEqual(p.get_meta(), {}) |
| 52 | 57 | ||
| 53 | os.remove('./tests/data/clean.png') | 58 | os.remove('./tests/data/clean.png') |
| 59 | |||
| 60 | |||
| 61 | def test_jpg(self): | ||
| 62 | shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') | ||
| 63 | p = jpg.JPGParser('./tests/data/clean.jpg') | ||
| 64 | |||
| 65 | meta = p.get_meta() | ||
| 66 | self.assertEqual(meta['Comment'], 'Created with GIMP') | ||
| 67 | |||
| 68 | ret = p.remove_all() | ||
| 69 | self.assertTrue(ret) | ||
| 70 | |||
| 71 | p = jpg.JPGParser('./tests/data/clean.jpg.cleaned') | ||
| 72 | self.assertEqual(p.get_meta(), {}) | ||
| 73 | |||
| 74 | os.remove('./tests/data/clean.jpg') | ||
