diff options
| author | jvoisin | 2019-08-31 10:31:08 -0700 |
|---|---|---|
| committer | jvoisin | 2019-08-31 10:31:08 -0700 |
| commit | 40669186c937a36fa73c16d5bba0f343005f398d (patch) | |
| tree | 015fbf9b6befa9563f5e01726163fca129a082bf /tests | |
| parent | d76a6cbb1832fb3337171edeb38e38b498ba4ef9 (diff) | |
Add support for inplace cleaning
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_climat2.py | 35 |
1 files changed, 33 insertions, 2 deletions
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): | |||
| 20 | def test_help(self): | 20 | def test_help(self): |
| 21 | proc = subprocess.Popen(mat2_binary + ['--help'], stdout=subprocess.PIPE) | 21 | proc = subprocess.Popen(mat2_binary + ['--help'], stdout=subprocess.PIPE) |
| 22 | stdout, _ = proc.communicate() | 22 | stdout, _ = proc.communicate() |
| 23 | self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [-v] [-l]', | 23 | self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [--inplace] [-v] [-l]', |
| 24 | stdout) | 24 | stdout) |
| 25 | self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) | 25 | self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) |
| 26 | self.assertIn(b'[files [files ...]]', stdout) | 26 | self.assertIn(b'[files [files ...]]', stdout) |
| @@ -28,7 +28,7 @@ class TestHelp(unittest.TestCase): | |||
| 28 | def test_no_arg(self): | 28 | def test_no_arg(self): |
| 29 | proc = subprocess.Popen(mat2_binary, stdout=subprocess.PIPE) | 29 | proc = subprocess.Popen(mat2_binary, stdout=subprocess.PIPE) |
| 30 | stdout, _ = proc.communicate() | 30 | stdout, _ = proc.communicate() |
| 31 | self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [-v] [-l]', | 31 | self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [--inplace] [-v] [-l]', |
| 32 | stdout) | 32 | stdout) |
| 33 | self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) | 33 | self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) |
| 34 | self.assertIn(b'[files [files ...]]', stdout) | 34 | self.assertIn(b'[files [files ...]]', stdout) |
| @@ -241,3 +241,34 @@ class TestCommandLineParallel(unittest.TestCase): | |||
| 241 | os.remove('./tests/data/dirty_%d.cleaned.jpg' % i) | 241 | os.remove('./tests/data/dirty_%d.cleaned.jpg' % i) |
| 242 | os.remove(path) | 242 | os.remove(path) |
| 243 | os.remove('./tests/data/dirty_%d.docx' % i) | 243 | os.remove('./tests/data/dirty_%d.docx' % i) |
| 244 | |||
| 245 | class TestInplaceCleaning(unittest.TestCase): | ||
| 246 | def test_cleaning(self): | ||
| 247 | shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') | ||
| 248 | proc = subprocess.Popen(mat2_binary + ['--inplace', './tests/data/clean.jpg'], | ||
| 249 | stdout=subprocess.PIPE) | ||
| 250 | stdout, _ = proc.communicate() | ||
| 251 | proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/clean.jpg'], | ||
| 252 | stdout=subprocess.PIPE) | ||
| 253 | stdout, _ = proc.communicate() | ||
| 254 | self.assertIn(b' No metadata found in ./tests/data/clean.jpg.\n', stdout) | ||
| 255 | os.remove('./tests/data/clean.jpg') | ||
| 256 | |||
| 257 | def test_cleaning_multiple_one_fails(self): | ||
| 258 | files = ['./tests/data/clean_%d.jpg' % i for i in range(9)] | ||
| 259 | for f in files: | ||
| 260 | shutil.copy('./tests/data/dirty.jpg', f) | ||
| 261 | shutil.copy('./tests/data/dirty.torrent', './tests/data/clean_9.jpg') | ||
| 262 | |||
| 263 | proc = subprocess.Popen(mat2_binary + ['--inplace'] + files, | ||
| 264 | stdout=subprocess.PIPE) | ||
| 265 | stdout, _ = proc.communicate() | ||
| 266 | |||
| 267 | for f in files: | ||
| 268 | p = images.JPGParser(f) | ||
| 269 | meta = p.get_meta() | ||
| 270 | self.assertEqual(meta, {}) | ||
| 271 | |||
| 272 | for i in range(10): | ||
| 273 | os.remove('./tests/data/clean_%d.jpg' % i) | ||
| 274 | |||
