From 40669186c937a36fa73c16d5bba0f343005f398d Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 31 Aug 2019 10:31:08 -0700 Subject: Add support for inplace cleaning --- tests/test_climat2.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'tests/test_climat2.py') diff --git a/tests/test_climat2.py b/tests/test_climat2.py index bbb9c06..6cf8a39 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py @@ -20,7 +20,7 @@ class TestHelp(unittest.TestCase): def test_help(self): proc = subprocess.Popen(mat2_binary + ['--help'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() - self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [-v] [-l]', + self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [--inplace] [-v] [-l]', stdout) self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) self.assertIn(b'[files [files ...]]', stdout) @@ -28,7 +28,7 @@ class TestHelp(unittest.TestCase): def test_no_arg(self): proc = subprocess.Popen(mat2_binary, stdout=subprocess.PIPE) stdout, _ = proc.communicate() - self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [-v] [-l]', + self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [--inplace] [-v] [-l]', stdout) self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) self.assertIn(b'[files [files ...]]', stdout) @@ -241,3 +241,34 @@ class TestCommandLineParallel(unittest.TestCase): os.remove('./tests/data/dirty_%d.cleaned.jpg' % i) os.remove(path) os.remove('./tests/data/dirty_%d.docx' % i) + +class TestInplaceCleaning(unittest.TestCase): + def test_cleaning(self): + shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') + proc = subprocess.Popen(mat2_binary + ['--inplace', './tests/data/clean.jpg'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/clean.jpg'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertIn(b' No metadata found in ./tests/data/clean.jpg.\n', stdout) + os.remove('./tests/data/clean.jpg') + + def test_cleaning_multiple_one_fails(self): + files = ['./tests/data/clean_%d.jpg' % i for i in range(9)] + for f in files: + shutil.copy('./tests/data/dirty.jpg', f) + shutil.copy('./tests/data/dirty.torrent', './tests/data/clean_9.jpg') + + proc = subprocess.Popen(mat2_binary + ['--inplace'] + files, + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + + for f in files: + p = images.JPGParser(f) + meta = p.get_meta() + self.assertEqual(meta, {}) + + for i in range(10): + os.remove('./tests/data/clean_%d.jpg' % i) + -- cgit v1.3