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

Test mat2's reliability wrt. corrupted video files

This commit is contained in:
jvoisin 2018-10-22 13:42:04 +02:00
parent e70ea811c9
commit 83389a63e9
3 changed files with 15 additions and 7 deletions

View File

@ -43,9 +43,8 @@ class AVIParser(exiftool.ExiftoolParser):
try: try:
subprocess.check_call(cmd) subprocess.check_call(cmd)
except subprocess.CalledProcessError: # pragma: no cover except subprocess.CalledProcessError:
return False return False
return True return True

View File

@ -5,7 +5,8 @@ import shutil
import os import os
import logging import logging
from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless from libmat2 import pdf, images, audio, office, parser_factory, torrent
from libmat2 import harmless, video
# No need to logging messages, should something go wrong, # No need to logging messages, should something go wrong,
# the testsuite _will_ fail. # the testsuite _will_ fail.
@ -192,3 +193,9 @@ class TestCorruptedFiles(unittest.TestCase):
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
images.JPGParser('./tests/data/clean.jpg') images.JPGParser('./tests/data/clean.jpg')
os.remove('./tests/data/clean.jpg') os.remove('./tests/data/clean.jpg')
def test_avi(self):
shutil.copy('./tests/data/dirty.torrent', './tests/data/clean.avi')
p = video.AVIParser('./tests/data/clean.avi')
self.assertFalse(p.remove_all())
os.remove('./tests/data/clean.avi')

View File

@ -477,16 +477,18 @@ class TestCleaning(unittest.TestCase):
os.remove('./tests/data/clean.cleaned.cleaned.txt') os.remove('./tests/data/clean.cleaned.cleaned.txt')
def test_avi(self): def test_avi(self):
try:
video._get_ffmpeg_path()
except RuntimeError:
raise unittest.SkipTest
shutil.copy('./tests/data/dirty.avi', './tests/data/clean.avi') shutil.copy('./tests/data/dirty.avi', './tests/data/clean.avi')
p = video.AVIParser('./tests/data/clean.avi') p = video.AVIParser('./tests/data/clean.avi')
meta = p.get_meta() meta = p.get_meta()
self.assertEqual(meta['Software'], 'MEncoder SVN-r33148-4.0.1') self.assertEqual(meta['Software'], 'MEncoder SVN-r33148-4.0.1')
try: ret = p.remove_all()
ret = p.remove_all()
except RuntimeError:
return # this happens if ffmepg is not installed
self.assertTrue(ret) self.assertTrue(ret)
p = video.AVIParser('./tests/data/clean.cleaned.avi') p = video.AVIParser('./tests/data/clean.cleaned.avi')