Commit b78940ca authored by Priscila Manhaes's avatar Priscila Manhaes

Refactor ffmpeghandler test to expect the correct mimetype, and testserver...

Refactor ffmpeghandler test to expect the correct mimetype, and testserver because test's name was wrong, and allsupportedformat for using enviroment

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43831 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c469a83b
...@@ -38,13 +38,14 @@ class TestAllFormats(HandlerTestCase): ...@@ -38,13 +38,14 @@ class TestAllFormats(HandlerTestCase):
def afterSetUp(self): def afterSetUp(self):
self.data = open("./data/test.ogv").read() self.data = open("./data/test.ogv").read()
self.input = FFMPEGHandler(self.tmp_url, self.data, "ogv") self.kw = dict(env=dict(PATH=self.env_path))
self.input = FFMPEGHandler(self.tmp_url, self.data, "ogv", **self.kw)
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") output_data = self.input.convert("avi")
output_format = file_detector.from_buffer(output_data) output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "avi") output = FFMPEGHandler(self.tmp_url, output_data, "avi", **self.kw)
input_data = output.convert("ogv") input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data) input_format = file_detector.from_buffer(input_data)
self.assertEquals(output_format, 'video/avi') self.assertEquals(output_format, 'video/avi')
...@@ -54,7 +55,7 @@ class TestAllFormats(HandlerTestCase): ...@@ -54,7 +55,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to mp4 format the reverse convertion""" """Test convert file to mp4 format the reverse convertion"""
output_data = self.input.convert("mp4") output_data = self.input.convert("mp4")
output_format = file_detector.from_buffer(output_data) output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "mp4") output = FFMPEGHandler(self.tmp_url, output_data, "mp4", **self.kw)
input_data = output.convert("ogv") input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data) input_format = file_detector.from_buffer(input_data)
self.assertEquals(output_format, 'video/mp4') self.assertEquals(output_format, 'video/mp4')
...@@ -64,7 +65,7 @@ class TestAllFormats(HandlerTestCase): ...@@ -64,7 +65,7 @@ class TestAllFormats(HandlerTestCase):
"""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") output_data = self.input.convert("webm")
output_format = file_detector.from_buffer(output_data) output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "webm") output = FFMPEGHandler(self.tmp_url, output_data, "webm", **self.kw)
input_data = output.convert("ogv") input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data) input_format = file_detector.from_buffer(input_data)
self.assertEquals(output_format, 'video/webm') self.assertEquals(output_format, 'video/webm')
...@@ -74,7 +75,7 @@ class TestAllFormats(HandlerTestCase): ...@@ -74,7 +75,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to flash format the reverse convertion""" """Test convert file to flash format the reverse convertion"""
output_data = self.input.convert("flv") output_data = self.input.convert("flv")
output_format = file_detector.from_buffer(output_data) output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "flv") output = FFMPEGHandler(self.tmp_url, output_data, "flv", **self.kw)
input_data = output.convert("ogv") input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data) input_format = file_detector.from_buffer(input_data)
self.assertEquals(output_format, 'application/x-shockwave-flash') self.assertEquals(output_format, 'application/x-shockwave-flash')
...@@ -84,7 +85,7 @@ class TestAllFormats(HandlerTestCase): ...@@ -84,7 +85,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to Mpeg format the reverse convertion""" """Test convert file to Mpeg format the reverse convertion"""
output_data = self.input.convert("mpeg") output_data = self.input.convert("mpeg")
output_format = file_detector.from_buffer(output_data) output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "mpeg") output = FFMPEGHandler(self.tmp_url, output_data, "mpeg", **self.kw)
input_data = output.convert("ogv") input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data) input_format = file_detector.from_buffer(input_data)
self.assertEquals(output_format, 'video/mpeg') self.assertEquals(output_format, 'video/mpeg')
...@@ -94,7 +95,7 @@ class TestAllFormats(HandlerTestCase): ...@@ -94,7 +95,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to matroska format the reverse convertion""" """Test convert file to matroska format the reverse convertion"""
output_data = self.input.convert("mkv") output_data = self.input.convert("mkv")
output_format = file_detector.from_buffer(output_data) output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "mkv") output = FFMPEGHandler(self.tmp_url, output_data, "mkv", **self.kw)
input_data = output.convert("ogv") input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data) input_format = file_detector.from_buffer(input_data)
self.assertEquals(output_format, 'video/x-matroska') self.assertEquals(output_format, 'video/x-matroska')
...@@ -104,7 +105,7 @@ class TestAllFormats(HandlerTestCase): ...@@ -104,7 +105,7 @@ class TestAllFormats(HandlerTestCase):
"""Test convert file to ogg format the reverse convertion""" """Test convert file to ogg format the reverse convertion"""
output_data = self.input.convert("ogg") output_data = self.input.convert("ogg")
output_format = file_detector.from_buffer(output_data) output_format = file_detector.from_buffer(output_data)
output = FFMPEGHandler(self.tmp_url, output_data, "ogg") output = FFMPEGHandler(self.tmp_url, output_data, "ogg", **self.kw)
input_data = output.convert("ogv") input_data = output.convert("ogv")
input_format = file_detector.from_buffer(input_data) input_format = file_detector.from_buffer(input_data)
self.assertEquals(output_format, 'application/ogg') self.assertEquals(output_format, 'application/ogg')
......
...@@ -40,10 +40,10 @@ class TestFFMPEGHandler(HandlerTestCase): ...@@ -40,10 +40,10 @@ class TestFFMPEGHandler(HandlerTestCase):
def testConvertVideo(self): def testConvertVideo(self):
"""Test coversion of video to another format""" """Test coversion of video to another format"""
file_detector = magic.Magic() file_detector = magic.Magic(mime=True)
output_data = self.input.convert("ogg") output_data = self.input.convert("mpeg")
file_format = file_detector.from_buffer(output_data) file_format = file_detector.from_buffer(output_data)
self.assertEqual(file_format, 'Ogg data, Theora video') self.assertEquals(file_format, 'video/mpeg')
def testgetMetadata(self): def testgetMetadata(self):
"""Test if metadata is extracted from""" """Test if metadata is extracted from"""
......
...@@ -43,7 +43,7 @@ class TestServer(HandlerTestCase): ...@@ -43,7 +43,7 @@ class TestServer(HandlerTestCase):
self.proxy = ServerProxy("http://%s:%s/RPC2" % \ self.proxy = ServerProxy("http://%s:%s/RPC2" % \
(self.hostname, self.cloudooo_port), allow_none=True) (self.hostname, self.cloudooo_port), allow_none=True)
def testConvertPDFtoTxt(self): def testConvertVideo(self):
"""Converts ogv video to mpeg format""" """Converts ogv video to mpeg format"""
data = open(join('data', 'test.ogv'), 'r').read() data = open(join('data', 'test.ogv'), 'r').read()
video = self.proxy.convertFile(encodestring(data), video = self.proxy.convertFile(encodestring(data),
......
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