summaryrefslogtreecommitdiff
path: root/tests/test_climat2.py
diff options
context:
space:
mode:
authorjvoisin2019-05-09 21:08:52 +0200
committerjvoisin2019-05-09 21:08:52 +0200
commitfe1950ac3ee8865e826b6d95a7f3bcf6260b9698 (patch)
tree4ff7a8fd9011ab7cd7d764b22bc44915aa66769b /tests/test_climat2.py
parent97abafdc5824936c3a72136c3f398eb3dbdfec3c (diff)
Test the cli's behaviour with valid and invalid files
This should ensure that if we decide to implement some threading in the cli, a faulty file won't break everything.
Diffstat (limited to 'tests/test_climat2.py')
-rw-r--r--tests/test_climat2.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_climat2.py b/tests/test_climat2.py
index 61f342b..4a46644 100644
--- a/tests/test_climat2.py
+++ b/tests/test_climat2.py
@@ -1,3 +1,4 @@
1import random
1import os 2import os
2import shutil 3import shutil
3import subprocess 4import subprocess
@@ -217,6 +218,24 @@ class TestCommandLineParallel(unittest.TestCase):
217 self.assertIsNotNone(p) 218 self.assertIsNotNone(p)
218 p = parser_factory.get_parser(p.output_filename) 219 p = parser_factory.get_parser(p.output_filename)
219 self.assertEqual(p.get_meta(), {}) 220 self.assertEqual(p.get_meta(), {})
220 print('DELET: %s' % i)
221 shutil.rmtree('./tests/data/parallel') 221 shutil.rmtree('./tests/data/parallel')
222 222
223 def test_faulty(self):
224 for i in range(self.iterations):
225 shutil.copy('./tests/data/dirty.jpg', './tests/data/dirty_%d.jpg' % i)
226 shutil.copy('./tests/data/dirty.torrent', './tests/data/dirty_%d.docx' % i)
227
228 to_process = ['./tests/data/dirty_%d.jpg' % i for i in range(self.iterations)]
229 to_process.extend(['./tests/data/dirty_%d.docx' % i for i in range(self.iterations)])
230 random.shuffle(to_process)
231 proc = subprocess.Popen(mat2_binary + to_process,
232 stdout=subprocess.PIPE)
233 stdout, _ = proc.communicate()
234
235 for i in range(self.iterations):
236 path = './tests/data/dirty_%d.jpg' % i
237 p = images.JPGParser('./tests/data/dirty_%d.cleaned.jpg' % i)
238 self.assertEqual(p.get_meta(), {})
239 os.remove('./tests/data/dirty_%d.cleaned.jpg' % i)
240 os.remove(path)
241 os.remove('./tests/data/dirty_%d.docx' % i)