Commit e4a1189f authored by Priscila Manhaes's avatar Priscila Manhaes

Refactor repeated code into the tests

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43858 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b78940ca
......@@ -34,20 +34,24 @@ from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
file_detector = Magic(mime=True)
class TestAllFormats(HandlerTestCase):
class TestAllSupportedFormats(HandlerTestCase):
def afterSetUp(self):
self.data = open("./data/test.ogv").read()
self.kw = dict(env=dict(PATH=self.env_path))
self.input = FFMPEGHandler(self.tmp_url, self.data, "ogv", **self.kw)
def afterFormat(self, output_data):
output = FFMPEGHandler(self.tmp_url, output_data, "avi", **self.kw)
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
return input_format
def testAviFormat(self):
"""Test convert file to avi format the reverse convertion"""
output_data = self.input.convert("avi")
output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "avi", **self.kw)
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
input_format = self.afterFormat(output_data)
self.assertEquals(output_format, 'video/avi')
self.assertEquals(input_format, 'video/ogg')
......@@ -55,9 +59,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to mp4 format the reverse convertion"""
output_data = self.input.convert("mp4")
output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "mp4", **self.kw)
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
input_format = self.afterFormat(output_data)
self.assertEquals(output_format, 'video/mp4')
self.assertEquals(input_format, 'video/ogg')
......@@ -65,9 +67,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to WebM format and the reverse convertion"""
output_data = self.input.convert("webm")
output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "webm", **self.kw)
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
input_format = self.afterFormat(output_data)
self.assertEquals(output_format, 'video/webm')
self.assertEquals(input_format, 'video/ogg')
......@@ -75,9 +75,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to flash format the reverse convertion"""
output_data = self.input.convert("flv")
output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "flv", **self.kw)
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
input_format = self.afterFormat(output_data)
self.assertEquals(output_format, 'application/x-shockwave-flash')
self.assertEquals(input_format, 'video/ogg')
......@@ -85,9 +83,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to Mpeg format the reverse convertion"""
output_data = self.input.convert("mpeg")
output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "mpeg", **self.kw)
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
input_format = self.afterFormat(output_data)
self.assertEquals(output_format, 'video/mpeg')
self.assertEquals(input_format, 'video/ogg')
......@@ -95,9 +91,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to matroska format the reverse convertion"""
output_data = self.input.convert("mkv")
output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "mkv", **self.kw)
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
input_format = self.afterFormat(output_data)
self.assertEquals(output_format, 'video/x-matroska')
self.assertEquals(input_format, 'video/ogg')
......@@ -105,12 +99,10 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to ogg format the reverse convertion"""
output_data = self.input.convert("ogg")
output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "ogg", **self.kw)
input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data)
input_format = self.afterFormat(output_data)
self.assertEquals(output_format, 'application/ogg')
self.assertEquals(input_format, 'video/ogg')
def test_suite():
return make_suite(TestAllFormats)
return make_suite(TestAllSupportedFormats)
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