diff options
| author | jvoisin | 2019-05-09 21:08:52 +0200 |
|---|---|---|
| committer | jvoisin | 2019-05-09 21:08:52 +0200 |
| commit | fe1950ac3ee8865e826b6d95a7f3bcf6260b9698 (patch) | |
| tree | 4ff7a8fd9011ab7cd7d764b22bc44915aa66769b /tests | |
| parent | 97abafdc5824936c3a72136c3f398eb3dbdfec3c (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')
| -rw-r--r-- | tests/test_climat2.py | 21 |
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 @@ | |||
| 1 | import random | ||
| 1 | import os | 2 | import os |
| 2 | import shutil | 3 | import shutil |
| 3 | import subprocess | 4 | import 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) | ||
