Commit c25d2a47 authored by Priscila Manhaes's avatar Priscila Manhaes

Refactor to leave viariables more compreensive and so tests response

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43865 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e4a1189f
...@@ -31,78 +31,76 @@ from cloudooo.handler.ffmpeg.handler import FFMPEGHandler ...@@ -31,78 +31,76 @@ from cloudooo.handler.ffmpeg.handler import FFMPEGHandler
from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
file_detector = Magic(mime=True) class TestAllSupportedFormat(HandlerTestCase):
class TestAllSupportedFormats(HandlerTestCase):
def afterSetUp(self): def afterSetUp(self):
self.data = open("./data/test.ogv").read() self.data = open("./data/test.ogv").read()
self.kw = dict(env=dict(PATH=self.env_path)) self.kw = dict(env=dict(PATH=self.env_path))
self.input = FFMPEGHandler(self.tmp_url, self.data, "ogv", **self.kw) self.input = FFMPEGHandler(self.tmp_url, self.data, "ogv", **self.kw)
self.file_detector = Magic(mime=True)
def afterFormat(self, output_data): def afterFormat(self, data):
output = FFMPEGHandler(self.tmp_url, output_data, "avi", **self.kw) ogv_file = FFMPEGHandler(self.tmp_url, data, "avi", **self.kw)
input_data = output.convert("ogv") ogv_data = ogv_file.convert("ogv")
input_format = file_detector.from_buffer(input_data) ogv_mimetype = self.file_detector.from_buffer(ogv_data)
return input_format return ogv_mimetype
def testAviFormat(self): def testAviFormat(self):
"""Test convert file to avi format the reverse convertion""" """Test convert file to avi format the reverse convertion"""
output_data = self.input.convert("avi") avi_data = self.input.convert("avi")
output_format = file_detector.from_buffer(output_data) avi_mimetype = self.file_detector.from_buffer(avi_data)
input_format = self.afterFormat(output_data) self.assertEquals(avi_mimetype, 'video/avi')
self.assertEquals(output_format, 'video/avi') ogv_mimetype = self.afterFormat(avi_data)
self.assertEquals(input_format, 'video/ogg') self.assertEquals(ogv_mimetype, 'video/ogg')
def testMp4Format(self): def testMp4Format(self):
"""Test convert file to mp4 format the reverse convertion""" """Test convert file to mp4 format the reverse convertion"""
output_data = self.input.convert("mp4") mp4_data = self.input.convert("mp4")
output_format = file_detector.from_buffer(output_data) mp4_mimetype = self.file_detector.from_buffer(mp4_data)
input_format = self.afterFormat(output_data) self.assertEquals(mp4_mimetype, 'video/mp4')
self.assertEquals(output_format, 'video/mp4') ogv_mimetype = self.afterFormat(mp4_data)
self.assertEquals(input_format, 'video/ogg') self.assertEquals(ogv_mimetype, 'video/ogg')
def testWebMFormat(self): def testWebMFormat(self):
"""Test convert file to WebM format and the reverse convertion""" """Test convert file to WebM format and the reverse convertion"""
output_data = self.input.convert("webm") webm_data = self.input.convert("webm")
output_format = file_detector.from_buffer(output_data) webm_mimetype = self.file_detector.from_buffer(webm_data)
input_format = self.afterFormat(output_data) self.assertEquals(webm_mimetype, 'video/webm')
self.assertEquals(output_format, 'video/webm') ogv_mimetype = self.afterFormat(webm_data)
self.assertEquals(input_format, 'video/ogg') self.assertEquals(ogv_mimetype, 'video/ogg')
def testFlvFormat(self): def testFlvFormat(self):
"""Test convert file to flash format the reverse convertion""" """Test convert file to flash format the reverse convertion"""
output_data = self.input.convert("flv") flv_data = self.input.convert("flv")
output_format = file_detector.from_buffer(output_data) flv_mimetype = self.file_detector.from_buffer(flv_data)
input_format = self.afterFormat(output_data) self.assertEquals(flv_mimetype, 'application/x-shockwave-flash')
self.assertEquals(output_format, 'application/x-shockwave-flash') ogv_mimetype = self.afterFormat(flv_data)
self.assertEquals(input_format, 'video/ogg') self.assertEquals(ogv_mimetype, 'video/ogg')
def testMpegFormat(self): def testMpegFormat(self):
"""Test convert file to Mpeg format the reverse convertion""" """Test convert file to Mpeg format the reverse convertion"""
output_data = self.input.convert("mpeg") mpeg_data = self.input.convert("mpeg")
output_format = file_detector.from_buffer(output_data) mpeg_mimetype = self.file_detector.from_buffer(mpeg_data)
input_format = self.afterFormat(output_data) self.assertEquals(mpeg_mimetype, 'video/mpeg')
self.assertEquals(output_format, 'video/mpeg') ogv_mimetype = self.afterFormat(mpeg_data)
self.assertEquals(input_format, 'video/ogg') self.assertEquals(ogv_mimetype, 'video/ogg')
def testMkvFormat(self): def testMkvFormat(self):
"""Test convert file to matroska format the reverse convertion""" """Test convert file to matroska format the reverse convertion"""
output_data = self.input.convert("mkv") mkv_data = self.input.convert("mkv")
output_format = file_detector.from_buffer(output_data) mkv_mimetype = self.file_detector.from_buffer(mkv_data)
input_format = self.afterFormat(output_data) self.assertEquals(mkv_mimetype, 'video/x-matroska')
self.assertEquals(output_format, 'video/x-matroska') ogv_mimetype = self.afterFormat(mkv_data)
self.assertEquals(input_format, 'video/ogg') self.assertEquals(ogv_mimetype, 'video/ogg')
def testOggFormat(self): def testOggFormat(self):
"""Test convert file to ogg format the reverse convertion""" """Test convert file to ogg format the reverse convertion"""
output_data = self.input.convert("ogg") ogg_data = self.input.convert("ogg")
output_format = file_detector.from_buffer(output_data) ogg_mimetype = self.file_detector.from_buffer(ogg_data)
input_format = self.afterFormat(output_data) self.assertEquals(ogg_mimetype, 'application/ogg')
self.assertEquals(output_format, 'application/ogg') ogv_mimetype = self.afterFormat(ogg_data)
self.assertEquals(input_format, 'video/ogg') self.assertEquals(ogv_mimetype, 'video/ogg')
def test_suite(): def test_suite():
return make_suite(TestAllSupportedFormats) return make_suite(TestAllSupportedFormat)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment