From d5861e46537f3e94abd26f63a3a7ad5b69d25e77 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 10 Jul 2018 20:49:54 +0200 Subject: Implement a check for dependencies in mat2 Example use: ``` $ mat2 -c Dependencies required for MAT2 0.1.3: - Cairo: yes - Exiftool: yes - GdkPixbuf from PyGobject: yes - Mutagen: yes - Poppler from PyGobject: yes - PyGobject: yes ``` This should close #35 --- tests/test_climat2.py | 9 +++++++-- tests/test_libmat2.py | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 9948057..99f9b9c 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py @@ -8,12 +8,12 @@ class TestHelp(unittest.TestCase): def test_help(self): proc = subprocess.Popen(['./mat2', '--help'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() - self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-s | -L] [files [files ...]]', stdout) + self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-s | -L] [files [files ...]]', stdout) def test_no_arg(self): proc = subprocess.Popen(['./mat2'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() - self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-s | -L] [files [files ...]]', stdout) + self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-s | -L] [files [files ...]]', stdout) class TestVersion(unittest.TestCase): @@ -22,6 +22,11 @@ class TestVersion(unittest.TestCase): stdout, _ = proc.communicate() self.assertTrue(stdout.startswith(b'MAT2 ')) +class TestDependencies(unittest.TestCase): + def test_dependencies(self): + proc = subprocess.Popen(['./mat2', '--check-dependencies'], stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertTrue(b'MAT2' in stdout) class TestReturnValue(unittest.TestCase): def test_nonzero(self): diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index cb37985..fa7e281 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py @@ -7,6 +7,14 @@ import zipfile import tempfile from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless +from libmat2 import check_dependencies + + +class TestCheckDependencies(unittest.TestCase): + def test_deps(self): + ret = check_dependencies() + for key, value in ret.items(): + self.assertTrue(value) class TestParserFactory(unittest.TestCase): -- cgit v1.3