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

refactor for using cloudoootestcase

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