From b5a9520a607bd368fdf538c61914e15ba6b1b8e3 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 30 Jul 2018 22:54:41 +0200 Subject: [PATCH] Add a cli-related test --- tests/test_climat2.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 99f9b9c..e65e47f 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py @@ -44,6 +44,33 @@ class TestReturnValue(unittest.TestCase): self.assertEqual(0, ret) +class TestCleanFolder(unittest.TestCase): + def test_jpg(self): + os.mkdir('./tests/data/folder/') + shutil.copy('./tests/data/dirty.jpg', './tests/data/folder/clean1.jpg') + shutil.copy('./tests/data/dirty.jpg', './tests/data/folder/clean2.jpg') + + proc = subprocess.Popen(['./mat2', '--show', './tests/data/folder/'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertIn(b'Comment: Created with GIMP', stdout) + + proc = subprocess.Popen(['./mat2', './tests/data/folder/'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + + os.remove('./tests/data/folder/clean1.jpg') + os.remove('./tests/data/folder/clean2.jpg') + + proc = subprocess.Popen(['./mat2', '--show', './tests/data/folder/'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertNotIn(b'Comment: Created with GIMP', stdout) + + shutil.rmtree('./tests/data/folder/') + + + class TestCleanMeta(unittest.TestCase): def test_jpg(self): shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg')