Commit fe1950ac authored by jvoisin's avatar jvoisin

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.
parent 97abafdc
Pipeline #24649 passed with stages
in 2 minutes and 31 seconds
import random
import os
import shutil
import subprocess
......@@ -217,6 +218,24 @@ class TestCommandLineParallel(unittest.TestCase):
self.assertIsNotNone(p)
p = parser_factory.get_parser(p.output_filename)
self.assertEqual(p.get_meta(), {})
print('DELET: %s' % i)
shutil.rmtree('./tests/data/parallel')
def test_faulty(self):
for i in range(self.iterations):
shutil.copy('./tests/data/dirty.jpg', './tests/data/dirty_%d.jpg' % i)
shutil.copy('./tests/data/dirty.torrent', './tests/data/dirty_%d.docx' % i)
to_process = ['./tests/data/dirty_%d.jpg' % i for i in range(self.iterations)]
to_process.extend(['./tests/data/dirty_%d.docx' % i for i in range(self.iterations)])
random.shuffle(to_process)
proc = subprocess.Popen(mat2_binary + to_process,
stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
for i in range(self.iterations):
path = './tests/data/dirty_%d.jpg' % i
p = images.JPGParser('./tests/data/dirty_%d.cleaned.jpg' % i)
self.assertEqual(p.get_meta(), {})
os.remove('./tests/data/dirty_%d.cleaned.jpg' % i)
os.remove(path)
os.remove('./tests/data/dirty_%d.docx' % i)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment