[Erp5-report] r43642 priscila.manhaes - in /erp5/trunk/utils/cloudooo/cloudooo/handler/ffmp...

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Feb 23 23:25:00 CET 2011


Author: priscila.manhaes
Date: Wed Feb 23 23:24:59 2011
New Revision: 43642

URL: http://svn.erp5.org?rev=43642&view=rev
Log:
 Implementing Ihandler into FFMPEGHandler and adding test for its server

Added:
    erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testInterface.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testServer.py
Modified:
    erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/handler.py

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/handler.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/handler.py?rev=43642&r1=43641&r2=43642&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/handler.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/handler.py [utf8] Wed Feb 23 23:24:59 2011
@@ -26,7 +26,8 @@
 #
 ##############################################################################
 
-
+from zope.interface import implements
+from cloudooo.interfaces.handler import IHandler
 from cloudooo.file import File
 from subprocess import Popen, PIPE
 from tempfile import mktemp
@@ -34,6 +35,8 @@ from tempfile import mktemp
 
 class FFMPEGHandler(object):
   """FFMPEGHandler is used to handler inputed video files"""
+  
+  implements(IHandler)
 
   def __init__(self, base_folder_url, data, source_format, **kw):
     """
@@ -69,3 +72,16 @@ class FFMPEGHandler(object):
       return self.input.getContent()
     finally:
       self.input.trash()
+  
+  def getMetadata(self, base_document=False):
+    """Returns a dictionary with all metadata of the video.
+    Keywords Arguments:
+    base_document -- Boolean variable. if true, the video is also returned
+    along with the metadata."""
+  
+  def setMetadata(self, metadata):
+    """Returns a document with new metadata.
+    Keyword arguments:
+    metadata -- expected an dictionary with metadata.
+    """
+  

Added: erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testInterface.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testInterface.py?rev=43642&view=auto
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testInterface.py (added)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testInterface.py [utf8] Wed Feb 23 23:24:59 2011
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+#                    Priscila Manhaes  <psilva at 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
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+import unittest
+from cloudooo.interfaces.handler import IHandler
+from cloudooo.handler.ffmpeg.handler import FFMPEGHandler
+from cloudooo.handler.tests.handlerTestCase import make_suite
+
+class TestInterface(unittest.TestCase):
+  """Test IHandler Interface"""
+
+  def testIHandler(self):
+    """Test if Handlers implements IHandler"""
+    self.assertTrue(IHandler.implementedBy(FFMPEGHandler))
+    method_list = ['convert', 'getMetadata', 'setMetadata']
+    for method in method_list:
+      self.assertTrue(method in IHandler.names(),
+                            "Method %s is not declared" % method)
+    self.assertEquals(len(method_list), len(IHandler.names()))
+    self.assertEquals(IHandler.get('convert').required, ('destination_format',))
+    self.assertEquals(IHandler.get('getMetadata').required,
+        ('converted_data',))
+    self.assertEquals(IHandler.get('setMetadata').required,
+        ('metadata_dict',))
+        
+
+def test_suite():
+  return make_suite(TestInterface)
+
+if __name__ == "__main__":
+  suite = unittest.TestLoader().loadTestsFromTestCase(TestInterface)
+  unittest.TextTestRunner(verbosity=2).run(suite)
+

Added: erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testServer.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testServer.py?rev=43642&view=auto
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testServer.py (added)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/testServer.py [utf8] Wed Feb 23 23:24:59 2011
@@ -0,0 +1,66 @@
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+#                    Priscila Manhaes  <psilva at 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
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
+from xmlrpclib import ServerProxy
+from os.path import join
+from base64 import encodestring, decodestring
+from magic import Magic
+
+DAEMON = True
+
+
+class TestServer(HandlerTestCase):
+  """Test XmlRpc Server. Needs cloudooo server started"""
+
+  def afterSetUp(self):
+    """Creates a connection with cloudooo server"""
+    self.proxy = ServerProxy("http://%s:%s/RPC2" % \
+        (self.hostname, self.cloudooo_port), allow_none=True)
+  
+  def testConvertPDFtoTxt(self):
+    """Converts ogv video to mpeg format"""
+    data = open(join('data', 'test.ogv'), 'r').read()
+    video = self.proxy.convertFile(encodestring(data),
+                                      "ogv",
+                                      "mpeg")
+    mime = Magic(mime=True)
+    mimetype = mime.from_buffer(decodestring(video))
+    self.assertEquals(mimetype, 'video/mpeg')
+  
+  def testGetMetadata(self):
+    """test if metadata are extracted correctly"""
+  
+  def testSetMetadata(self):
+    """Test if metadata is inserted correctly"""
+
+
+
+def test_suite():
+  return make_suite(TestServer)
+



More information about the Erp5-report mailing list