summaryrefslogtreecommitdiff
path: root/tests/test_libmat2.py
diff options
context:
space:
mode:
authorjvoisin2018-10-18 19:19:56 +0200
committerjvoisin2018-10-22 12:58:01 +0200
commite70ea811c99c16f3382c08153eda573df0825536 (patch)
treef1c05ca94b9d2ab09f74cfa6c7191bf73bf104e2 /tests/test_libmat2.py
parent2ae5d909c3e30c009bfc45bceba96ddd82f3e198 (diff)
Implement support for .avi files, via ffmpeg
- This commit introduces optional dependencies (namely ffmpeg): mat2 will spit a warning when trying to process an .avi file if ffmpeg isn't installed. - Since metadata are obtained via exiftool, this commit also refactors a bit our exfitool wrapper.
Diffstat (limited to 'tests/test_libmat2.py')
-rw-r--r--tests/test_libmat2.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 665bab0..37adc6a 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -6,12 +6,16 @@ import os
6import zipfile 6import zipfile
7 7
8from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless 8from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless
9from libmat2 import check_dependencies 9from libmat2 import check_dependencies, video
10 10
11 11
12class TestCheckDependencies(unittest.TestCase): 12class TestCheckDependencies(unittest.TestCase):
13 def test_deps(self): 13 def test_deps(self):
14 ret = check_dependencies() 14 try:
15 ret = check_dependencies()
16 except RuntimeError:
17 return # this happens if not every dependency is installed
18
15 for value in ret.values(): 19 for value in ret.values():
16 self.assertTrue(value) 20 self.assertTrue(value)
17 21
@@ -471,3 +475,24 @@ class TestCleaning(unittest.TestCase):
471 os.remove('./tests/data/clean.txt') 475 os.remove('./tests/data/clean.txt')
472 os.remove('./tests/data/clean.cleaned.txt') 476 os.remove('./tests/data/clean.cleaned.txt')
473 os.remove('./tests/data/clean.cleaned.cleaned.txt') 477 os.remove('./tests/data/clean.cleaned.cleaned.txt')
478
479 def test_avi(self):
480 shutil.copy('./tests/data/dirty.avi', './tests/data/clean.avi')
481 p = video.AVIParser('./tests/data/clean.avi')
482
483 meta = p.get_meta()
484 self.assertEqual(meta['Software'], 'MEncoder SVN-r33148-4.0.1')
485
486 try:
487 ret = p.remove_all()
488 except RuntimeError:
489 return # this happens if ffmepg is not installed
490 self.assertTrue(ret)
491
492 p = video.AVIParser('./tests/data/clean.cleaned.avi')
493 self.assertEqual(p.get_meta(), {})
494 self.assertTrue(p.remove_all())
495
496 os.remove('./tests/data/clean.avi')
497 os.remove('./tests/data/clean.cleaned.avi')
498 os.remove('./tests/data/clean.cleaned.cleaned.avi')