From ecb199b4a6a2f54b84237d4f74c145a051c4c08b Mon Sep 17 00:00:00 2001
From: jvoisin <julien.voisin@dustri.org>
Date: Mon, 16 Apr 2018 23:20:21 +0200
Subject: [PATCH] Add a cli-related test

Since I didn't notice that it was broken
until c5f51345029440ab80cfa1670d554a9d851d57c4,
it's a good idea to have some tests for this ;)
---
 tests/test_climat2.py | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/tests/test_climat2.py b/tests/test_climat2.py
index 64345eb..0536646 100644
--- a/tests/test_climat2.py
+++ b/tests/test_climat2.py
@@ -1,5 +1,7 @@
-import unittest
+import os
+import shutil
 import subprocess
+import unittest
 
 
 class TestHelp(unittest.TestCase):
@@ -14,6 +16,27 @@ class TestHelp(unittest.TestCase):
         self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [-L] [files [files ...]]', stdout)
 
 
+class TestCleanMeta(unittest.TestCase):
+    def test_jpg(self):
+        shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg')
+
+        proc = subprocess.Popen(['./main.py', '--show', './tests/data/clean.jpg'],
+                stdout=subprocess.PIPE)
+        stdout, _ = proc.communicate()
+        self.assertIn(b'Comment: Created with GIMP', stdout)
+
+        proc = subprocess.Popen(['./main.py', './tests/data/clean.jpg'],
+                stdout=subprocess.PIPE)
+        stdout, _ = proc.communicate()
+
+        proc = subprocess.Popen(['./main.py', '--show', './tests/data/clean.jpg.cleaned'],
+                stdout=subprocess.PIPE)
+        stdout, _ = proc.communicate()
+        self.assertNotIn(b'Comment: Created with GIMP', stdout)
+
+        os.remove('./tests/data/clean.jpg')
+
+
 class TestGetMeta(unittest.TestCase):
     def test_pdf(self):
         proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.pdf'],
-- 
GitLab