1
0
mirror of synced 2024-11-22 01:04:23 +01:00

Add a cli-related test

Since I didn't notice that it was broken
until c5f5134502,
it's a good idea to have some tests for this ;)
This commit is contained in:
jvoisin 2018-04-16 23:20:21 +02:00
parent e34bc19f71
commit ecb199b4a6

View File

@ -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'],