summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_climat2.py4
-rw-r--r--tests/test_libmat2.py31
2 files changed, 33 insertions, 2 deletions
diff --git a/tests/test_climat2.py b/tests/test_climat2.py
index b9c52b5..64345eb 100644
--- a/tests/test_climat2.py
+++ b/tests/test_climat2.py
@@ -6,12 +6,12 @@ class TestHelp(unittest.TestCase):
6 def test_help(self): 6 def test_help(self):
7 proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE) 7 proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE)
8 stdout, _ = proc.communicate() 8 stdout, _ = proc.communicate()
9 self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [files [files ...]]', stdout) 9 self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [-L] [files [files ...]]', stdout)
10 10
11 def test_no_arg(self): 11 def test_no_arg(self):
12 proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE) 12 proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE)
13 stdout, _ = proc.communicate() 13 stdout, _ = proc.communicate()
14 self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [files [files ...]]', stdout) 14 self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [-L] [files [files ...]]', stdout)
15 15
16 16
17class TestGetMeta(unittest.TestCase): 17class TestGetMeta(unittest.TestCase):
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 6141dbe..34f7301 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -138,6 +138,37 @@ class TestDeepCleaning(unittest.TestCase):
138 138
139 os.remove('./tests/data/clean.odt') 139 os.remove('./tests/data/clean.odt')
140 140
141class TestLightWeightCleaning(unittest.TestCase):
142 def test_pdf(self):
143 shutil.copy('./tests/data/dirty.pdf', './tests/data/clean.pdf')
144 p = pdf.PDFParser('./tests/data/clean.pdf')
145
146 meta = p.get_meta()
147 self.assertEqual(meta['producer'], 'pdfTeX-1.40.14')
148
149 ret = p.remove_all_lightweight()
150 self.assertTrue(ret)
151
152 p = pdf.PDFParser('./tests/data/clean.pdf.cleaned')
153 expected_meta = {'creation-date': -1, 'format': 'PDF-1.5', 'mod-date': -1}
154 self.assertEqual(p.get_meta(), expected_meta)
155
156 os.remove('./tests/data/clean.pdf')
157
158 def test_png(self):
159 shutil.copy('./tests/data/dirty.png', './tests/data/clean.png')
160 p = images.PNGParser('./tests/data/clean.png')
161
162 meta = p.get_meta()
163 self.assertEqual(meta['Comment'], 'This is a comment, be careful!')
164
165 ret = p.remove_all_lightweight()
166 self.assertTrue(ret)
167
168 p = images.PNGParser('./tests/data/clean.png.cleaned')
169 self.assertEqual(p.get_meta(), {})
170
171 os.remove('./tests/data/clean.png')
141 172
142class TestCleaning(unittest.TestCase): 173class TestCleaning(unittest.TestCase):
143 def test_pdf(self): 174 def test_pdf(self):