Commit 7f93b479 authored by Priscila Manhaes's avatar Priscila Manhaes

refactor for using cloudoootestcase

parent 2e0fa871
......@@ -26,83 +26,29 @@
#
##############################################################################
from magic import Magic
from xmlrpclib import ServerProxy
from os.path import join
from base64 import encodestring, decodestring
from cloudooo.tests.handlerTestCase import HandlerTestCase, make_suite
DAEMON = True
class TestAllSupportedFormat(HandlerTestCase):
"""Test XmlRpc Server. Needs cloudooo server started"""
def afterSetUp(self):
self.file_detector = Magic(mime=True)
self.proxy = ServerProxy("http://%s:%s/RPC2" % \
(self.hostname, self.cloudooo_port), allow_none=True)
def testAviFormat(self):
"""Test convert file to avi format the reverse convertion"""
avi_mimetype, ogv_mimetype = self.runTestForType("avi")
# XXX this might expect 'video/avi' but magic only got 'video/x-msvideo'
self.assertEquals(avi_mimetype, 'video/x-msvideo')
# XXX This might expect 'video/ogg' but magic only got 'application/ogg'
self.assertEquals(ogv_mimetype, 'application/ogg')
def testMp4Format(self):
"""Test convert file to mp4 format the reverse convertion"""
mp4_mimetype, ogv_mimetype = self.runTestForType("mp4")
self.assertEquals(mp4_mimetype, 'video/mp4')
# XXX This might expect 'video/ogg' but magic only got 'application/ogg'
self.assertEquals(ogv_mimetype, 'application/ogg')
def testWebMFormat(self):
"""Test convert file to WebM format and the reverse convertion"""
webm_mimetype, ogv_mimetype = self.runTestForType("webm")
self.assertEquals(webm_mimetype, 'video/webm')
# XXX This might expect 'video/ogg' but magic only got 'application/ogg'
self.assertEquals(ogv_mimetype, 'application/ogg')
def testFlvFormat(self):
"""Test convert file to flash format the reverse convertion"""
flv_mimetype, ogv_mimetype = self.runTestForType("flv")
# XXX this might expect 'application/x-shockwave-flash' but magic only got
# 'video/x-flv'
self.assertEquals(flv_mimetype, 'video/x-flv')
# XXX This might expect 'video/ogg' but magic only got 'application/ogg'
self.assertEquals(ogv_mimetype, 'application/ogg')
def testMpegFormat(self):
"""Test convert file to Mpeg format the reverse convertion"""
mpeg_mimetype, ogv_mimetype = self.runTestForType("mpeg")
self.assertEquals(mpeg_mimetype, 'video/mpeg')
# XXX This might expect 'video/ogg' but magic only got 'application/ogg'
self.assertEquals(ogv_mimetype, 'application/ogg')
def testMkvFormat(self):
"""Test convert file to matroska format the reverse convertion"""
mkv_mimetype, ogv_mimetype = self.runTestForType("mkv")
# XXX This might expect 'video/x-matroska' but magic only got
# 'application/octet-stream'
self.assertEquals(mkv_mimetype, 'application/octet-stream')
# XXX This might expect 'video/ogg' but magic only got 'application/ogg'
self.assertEquals(ogv_mimetype, 'application/ogg')
def runTestForType(self, destination_format):
"""Converts video files from ogv to destination_format and then to
ogv again"""
data = open(join('data', 'test.ogv'), 'r').read()
converted_data = self.proxy.convertFile(encodestring(data),
"ogv",
destination_format)
destination_mimetype = self.file_detector.from_buffer(decodestring(
converted_data))
ogv_data = self.proxy.convertFile(converted_data,
destination_format,
"ogv")
ogv_mimetype = self.file_detector.from_buffer(decodestring(ogv_data))
return (destination_mimetype, ogv_mimetype)
from cloudooo.tests.cloudoooTestCase import TestCase, make_suite
class TestAllSupportedFormat(TestCase):
def ConversionScenarioList(self):
return [
# XXX this might expect 'video/avi' but magic only got
# 'video/x-msvideo'
(join('data', 'test.ogv'), "ogv", "avi", "video/x-msvideo"),
# XXX this might expect 'application/x-shockwave-flash' but magic
# only got 'video/x-flv'
(join('data', 'test.ogv'), "ogv", "flv", "video/x-flv"),
# XXX This might expect video/x-matroska but only
# got application/octet-stream
(join('data', 'test.ogv'), "ogv", "mkv", "application/octet-stream"),
(join('data', 'test.ogv'), "ogv", "mp4", "video/mp4"),
(join('data', 'test.ogv'), "ogv", "mpeg", "video/mpeg"),
(join('data', 'test.ogv'), "ogv", "webm", "video/webm"),
]
def testAllSupportedFormat(self):
self.runConversionList(self.ConversionScenarioList())
def test_suite():
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