Commit c318eacc authored by Priscila Manhaes's avatar Priscila Manhaes

adding main unittest for ffmpeg handler, but it still early draft

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43534 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 51371fcf
......@@ -27,8 +27,6 @@
##############################################################################
from zope.interface import implements
from cloudooo.interfaces.handler import IHandler
from cloudooo.file import File
from subprocess import Popen, PIPE
......@@ -36,9 +34,7 @@ from subprocess import Popen, PIPE
class FFMPEGHandler(object):
"""FFMPEGHandler is used to handler inputed video files"""
implements(IHandler)
def __init__(self, base_folder_url, data, source_format, **kw):
def __init__(self, base_folder_url, data, source_format):
"""
base_folder_url(string)
The requested url for data base folder
......@@ -50,7 +46,7 @@ class FFMPEGHandler(object):
self.input = File(base_folder_url, data, source_format)
self.ffmpeg_bin = "/usr/bin/ffmpeg"
def convert(self, destination_format, **kw):
def convert(self, destination_format):
""" Convert the inputed video to output as format that were informed """
# XXX This implementation could use ffmpeg -i pipe:0, but
# XXX seems super unreliable currently and it generates currupted files in
......
#!/usr/bin/env python
import sys
import unittest
from argparse import ArgumentParser
from os import path, curdir, environ, chdir
ENVIRONMENT_PATH = path.abspath(path.dirname(__file__))
def exit(msg):
sys.stderr.write(msg)
sys.exit(0)
# XXX - Duplicated function. This function must be generic to be used by all handlers
def run():
parser = ArgumentParser(description="Unit Test Runner for Cloudooo")
parser.add_argument('server_cloudooo_conf')
parser.add_argument('test_name')
parser.add_argument('--paster_path', dest='paster_path',
default='paster',
help="Path to Paster script")
namespace = parser.parse_args()
server_cloudooo_conf = namespace.server_cloudooo_conf
test_name = namespace.test_name
if server_cloudooo_conf.startswith(curdir):
server_cloudooo_conf = path.join(path.abspath(curdir),
server_cloudooo_conf)
environ['server_cloudooo_conf'] = server_cloudooo_conf
python_extension = '.py'
if test_name[-3:] == python_extension:
test_name = test_name[:-3]
if not path.exists(path.join(ENVIRONMENT_PATH,
'%s%s' % (test_name, python_extension))):
exit("%s not exists\n" % test_name)
sys.path.append(ENVIRONMENT_PATH)
module = __import__(test_name)
if not hasattr(module, "test_suite"):
exit("No test suite to run, exiting immediately")
TestRunner = unittest.TextTestRunner
suite = unittest.TestSuite()
suite.addTest(module.test_suite())
chdir(ENVIRONMENT_PATH)
TestRunner(verbosity=2).run(suite)
if __name__ == "__main__":
run()
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Priscila Manhães <psilva@iff.edu.br>
# Priscila Manhaes <psilva@iff.edu.br>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
......@@ -27,20 +27,28 @@
##############################################################################
import unittest
import md5
import sha
from cloudooo.handler.ffmpeg.handler import FFMPEGHandler
from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
class TestFFMPEGHandler(unittest.TestCase):
class TestFFMPEGHandler(HandlerTestCase):
def setUp(self):
self.data = open("./data/test.3gp").read()
self.input = FFMPEGHandler("./data", self.data
,"3gp")
def testConvertVideo(self):
"""Test coversion of diferents formats of video"""
input_data = FFMPEGHandler("tests/data",
open("tests/data/test.3gp").read())
"""Test coversion of video to another format"""
# XXX - Hash might use md5, but it does not work for string
input_data = sha.new(self.data)
hash_input = input_data.digest()
output_data = handler.convert("ogv")
hash_output = output_data.digest()
self.assertTrue(hash_input == hash_output)
output_data = self.input.convert("ogv")
output = sha.new(output_data)
hash_output = output.digest()
self.assertTrue(hash_input != hash_output)
def test_suite():
......
......@@ -53,5 +53,6 @@ setup(name='cloudooo',
echo_cloudooo_conf = cloudooo.bin.echo_cloudooo_conf:main
runCloudOOoUnitTest = cloudooo.handler.ooo.tests.runCloudOOoUnitTest:run
runPDFHandlerUnitTest = cloudooo.handler.pdf.tests.runPDFHandlerUnitTest:run
runFFMPEGHandlerUnitTest = cloudooo.handler.ffmpeg.tests.runFFMPEGHandlerUnitTest:run
""",
)
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