From 6c19e43e5dea72a0b15d4b1291544b1d626149d7 Mon Sep 17 00:00:00 2001 From: jvoisin <julien.voisin@dustri.org> Date: Wed, 4 Apr 2018 00:37:55 +0200 Subject: [PATCH] Add even more tests for the cli --- tests/test_climat2.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/test_climat2.py b/tests/test_climat2.py index a0bcafc..16f97a2 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py @@ -8,3 +8,38 @@ class TestHelp(unittest.TestCase): proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [files [files ...]]', stdout) + +class TestGetMeta(unittest.TestCase): + def test_pdf(self): + proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.pdf'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertIn(b'producer: pdfTeX-1.40.14', stdout) + + def test_png(self): + proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.png'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertIn(b'Comment: This is a comment, be careful!', stdout) + + def test_jpg(self): + proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.jpg'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertIn(b'Comment: Created with GIMP', stdout) + + def test_docx(self): + proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.docx'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertIn(b'Application: LibreOffice/5.4.5.1$Linux_X86_64', stdout) + self.assertIn(b'creator: julien voisin', stdout) + self.assertIn(b'revision: 1', stdout) + + def test_odt(self): + proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.odt'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertIn(b'generator: LibreOffice/3.3$Unix', stdout) + self.assertIn(b'creator: jvoisin', stdout) + self.assertIn(b'date_time: 2011-07-26 02:40:16', stdout) -- GitLab