[Erp5-report] r43500 gabriel - in /erp5/trunk/utils/cloudooo/cloudooo: ./ handler/ooo/tests...

nobody at svn.erp5.org nobody at svn.erp5.org
Sun Feb 20 20:31:57 CET 2011


Author: gabriel
Date: Sun Feb 20 20:31:57 2011
New Revision: 43500

URL: http://svn.erp5.org?rev=43500&view=rev
Log:
refactor tests to prevent code duplicated. Part of cloudoooTestCase.py was added in handlerTestCase.py to each handler implement your test case only when needed.

Added:
    erp5/trunk/utils/cloudooo/cloudooo/handler/tests/
    erp5/trunk/utils/cloudooo/cloudooo/handler/tests/__init__.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py
Modified:
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/cloudoooTestCase.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormats.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormatsERP5Compatibility.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testHighLoad.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMimemapper.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorInit.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorRequest.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOGranulator.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOHandler.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOdfDocument.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOpenOffice.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testServer.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoConverter.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoMimemapper.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/handler.py
    erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/testPDFHandler.py
    erp5/trunk/utils/cloudooo/cloudooo/paster_application.py

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/cloudoooTestCase.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/cloudoooTestCase.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/cloudoooTestCase.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/cloudoooTestCase.py [utf8] Sun Feb 20 20:31:57 2011
@@ -28,24 +28,16 @@
 
 import unittest
 import sys
-from ConfigParser import ConfigParser
 from os import path, mkdir
 from os import environ, putenv
 from cloudooo.handler.ooo.application.openoffice import openoffice
 from cloudooo.handler.ooo.utils.utils import waitStartDaemon
 from cloudooo.handler.ooo.mimemapper import mimemapper
+from cloudooo.handler.tests.handlerTestCase import config, check_folder
 
-config = ConfigParser()
 testcase_path = path.dirname(__file__)
 
 
-def check_folder(working_path, tmp_dir_path):
-  if not path.exists(working_path):
-    mkdir(working_path)
-  if not path.exists(tmp_dir_path):
-    mkdir(tmp_dir_path)
-
-
 def make_suite(test_case):
   """Function is used to run all tests together"""
   suite = unittest.TestSuite()
@@ -103,27 +95,3 @@ def stopFakeEnvironment(stop_openoffice=
   if stop_openoffice:
     openoffice.stop()
   return True
-
-
-class CloudoooTestCase(unittest.TestCase):
-  """Test Case to load cloudooo conf."""
-
-  def setUp(self):
-    """Creates a environment to run the tests. Is called always before the
-    tests."""
-    server_cloudooo_conf = environ.get("server_cloudooo_conf", None)
-    if server_cloudooo_conf is not None:
-      config.read(server_cloudooo_conf)
-    self.hostname = config.get("server:main", "host")
-    self.cloudooo_port = config.get("server:main", "port")
-    self.openoffice_port = config.get("app:main", "openoffice_port")
-    self.office_binary_path = config.get("app:main", "office_binary_path")
-    self.python_path = sys.executable
-    self.working_path = config.get("app:main", "working_path")
-    self.tmp_url = path.join(self.working_path, "tmp")
-    check_folder(self.working_path, self.tmp_url)
-    self.uno_path = config.get("app:main", "uno_path")
-    self.afterSetUp()
-
-  def afterSetUp(self):
-    """ """

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormats.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormats.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormats.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormats.py [utf8] Sun Feb 20 20:31:57 2011
@@ -28,13 +28,14 @@
 
 from xmlrpclib import ServerProxy, Fault
 from base64 import encodestring, decodestring
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 import magic
 
 file_detector = magic.Magic()
 DAEMON = True
 
-class TestAllFormats(CloudoooTestCase):
+class TestAllFormats(HandlerTestCase):
   """Test XmlRpc Server. Needs cloudooo server started"""
 
   def afterSetUp(self):

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormatsERP5Compatibility.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormatsERP5Compatibility.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormatsERP5Compatibility.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testAllFormatsERP5Compatibility.py [utf8] Sun Feb 20 20:31:57 2011
@@ -28,13 +28,14 @@
 
 from xmlrpclib import ServerProxy, Fault
 from base64 import encodestring, decodestring
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 import magic
 
 file_detector = magic.Magic()
 DAEMON = True
 
-class TestAllFormatsERP5Compatibility(CloudoooTestCase):
+class TestAllFormatsERP5Compatibility(HandlerTestCase):
   """
   Test XmlRpc Server using ERP5 compatibility API.
   Needs cloudooo server started

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testHighLoad.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testHighLoad.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testHighLoad.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testHighLoad.py [utf8] Sun Feb 20 20:31:57 2011
@@ -29,7 +29,8 @@
 from xmlrpclib import ServerProxy
 from base64 import encodestring, decodestring
 from multiprocessing import Process, Array
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 import magic
 
 DAEMON = True
@@ -43,7 +44,7 @@ def basicTestToGenerate(id, proxy, data,
   assert mimetype == 'application/pdf'
   result_list[id] = True
 
-class TestHighLoad(CloudoooTestCase):
+class TestHighLoad(HandlerTestCase):
   """Test with many simultaneous connection"""
 
   def afterSetUp(self):

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMimemapper.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMimemapper.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMimemapper.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMimemapper.py [utf8] Sun Feb 20 20:31:57 2011
@@ -26,7 +26,7 @@
 #
 ##############################################################################
 
-from cloudoooTestCase import CloudoooTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 from cloudooo.handler.ooo.application.openoffice import openoffice
 from cloudooo.handler.ooo.mimemapper import MimeMapper
 from cloudoooTestCase import make_suite
@@ -164,7 +164,7 @@ chart_expected_tuple = (
 
 OPENOFFICE = True
 
-class TestMimeMapper(CloudoooTestCase):
+class TestMimeMapper(HandlerTestCase):
   """Test if object load filters correctly of OOo."""
 
   def afterSetUp(self):

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorInit.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorInit.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorInit.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorInit.py [utf8] Sun Feb 20 20:31:57 2011
@@ -27,13 +27,14 @@
 ##############################################################################
 
 import cloudooo.handler.ooo.monitor as monitor
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 from cloudooo.handler.ooo.monitor.request import MonitorRequest
 from cloudooo.handler.ooo.monitor.memory import MonitorMemory
 
 OPENOFFICE = True
 
-class TestMonitorInit(CloudoooTestCase):
+class TestMonitorInit(HandlerTestCase):
   """Test Case to test if the monitors are controlled correctly"""
 
   def afterSetUp(self):

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorRequest.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorRequest.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorRequest.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorRequest.py [utf8] Sun Feb 20 20:31:57 2011
@@ -28,12 +28,13 @@
 
 from time import sleep
 from cloudooo.handler.ooo.monitor.request import MonitorRequest
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 from cloudooo.handler.ooo.application.openoffice import openoffice
 
 OPENOFFICE = True
 
-class TestMonitorRequest(CloudoooTestCase):
+class TestMonitorRequest(HandlerTestCase):
   """Test all features of a monitor following the interface"""
 
   def testMonitorTerminate(self):

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOGranulator.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOGranulator.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOGranulator.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOGranulator.py [utf8] Sun Feb 20 20:31:57 2011
@@ -30,11 +30,12 @@
 from zipfile import ZipFile
 from StringIO import StringIO
 from lxml import etree
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 from cloudooo.handler.ooo.granulator import OOGranulator
 
 
-class TestOOGranulator(CloudoooTestCase):
+class TestOOGranulator(HandlerTestCase):
 
   def setUp(self):
     data = open('./data/granulate_test.odt').read()

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOHandler.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOHandler.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOHandler.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOOHandler.py [utf8] Sun Feb 20 20:31:57 2011
@@ -29,7 +29,7 @@
 import magic
 from os import path
 from base64 import encodestring, decodestring
-from cloudoooTestCase import CloudoooTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 from cloudooo.handler.ooo.handler import OOHandler
 from cloudooo.handler.ooo.application.openoffice import openoffice
 from cloudoooTestCase import make_suite
@@ -39,7 +39,7 @@ from zipfile import ZipFile
 
 OPENOFFICE = True
 
-class TestOOHandler(CloudoooTestCase):
+class TestOOHandler(HandlerTestCase):
   """Test OOHandler and manipulation of OOo Instance"""
 
   _file_path_list = []
@@ -64,7 +64,7 @@ class TestOOHandler(CloudoooTestCase):
       file_path = self._file_path_list.pop()
       if os.path.exists(file_path):
         os.remove(file_path)
-    CloudoooTestCase.tearDown(self)
+    HandlerTestCase.tearDown(self)
 
   def testConvertOdtToDoc(self):
     """Test convert ODT to DOC"""

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOdfDocument.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOdfDocument.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOdfDocument.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOdfDocument.py [utf8] Sun Feb 20 20:31:57 2011
@@ -28,10 +28,11 @@
 
 from zipfile import ZipFile
 from lxml import etree
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 from cloudooo.handler.ooo.document import OdfDocument
 
-class TestOdfDocument(CloudoooTestCase):
+class TestOdfDocument(HandlerTestCase):
 
   def setUp(self):
     data = open('./data/granulate_test.odt').read()

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOpenOffice.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOpenOffice.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOpenOffice.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testOpenOffice.py [utf8] Sun Feb 20 20:31:57 2011
@@ -26,14 +26,14 @@
 #
 ##############################################################################
 
-from cloudoooTestCase import CloudoooTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 from cloudooo.handler.ooo.application.openoffice import OpenOffice
 from cloudoooTestCase import make_suite
 from cloudooo.handler.ooo.utils.utils import waitStopDaemon
 
 OPENOFFICE = True
 
-class TestOpenOffice(CloudoooTestCase):
+class TestOpenOffice(HandlerTestCase):
   """Test OpenOffice object and manipulation of OOo Instance"""
 
   def afterSetUp(self):

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testServer.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testServer.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testServer.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testServer.py [utf8] Sun Feb 20 20:31:57 2011
@@ -30,14 +30,15 @@ from os.path import join, exists
 from os import remove
 from xmlrpclib import ServerProxy, Fault
 from base64 import encodestring, decodestring
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 from zipfile import ZipFile, is_zipfile
 from types import DictType
 import magic
 
 DAEMON = True
 
-class TestServer(CloudoooTestCase):
+class TestServer(HandlerTestCase):
   """Test XmlRpc Server. Needs cloudooo server started"""
 
   def afterSetUp(self):

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoConverter.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoConverter.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoConverter.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoConverter.py [utf8] Sun Feb 20 20:31:57 2011
@@ -31,13 +31,14 @@ import magic
 import pkg_resources
 from subprocess import Popen, PIPE
 from os.path import exists, join
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 from cloudooo.handler.ooo.application.openoffice import openoffice
 from cloudooo.handler.ooo.document import FileSystemDocument
 
 OPENOFFICE = True
 
-class TestUnoConverter(CloudoooTestCase):
+class TestUnoConverter(HandlerTestCase):
   """Test case to test all features of the unoconverter script"""
 
   file_msg_list = ["Microsoft Office Document",

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoMimemapper.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoMimemapper.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoMimemapper.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUnoMimemapper.py [utf8] Sun Feb 20 20:31:57 2011
@@ -31,11 +31,12 @@ import pkg_resources
 from cloudooo.handler.ooo.application.openoffice import openoffice
 from subprocess import Popen, PIPE
 from os import environ, path
-from cloudoooTestCase import CloudoooTestCase, make_suite
+from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
 
 OPENOFFICE = True
 
-class TestUnoMimeMapper(CloudoooTestCase):
+class TestUnoMimeMapper(HandlerTestCase):
   """Test Case to test all features of script unomimemapper"""
 
   def afterSetUp(self):

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/handler.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/handler.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/handler.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/handler.py [utf8] Sun Feb 20 20:31:57 2011
@@ -60,10 +60,24 @@ class PDFHandler(object):
 
   def getMetadata(self, base_document=False):
     """Returns a dictionary with all metadata of document.
-    Keywords Arguments:
-    base_document -- Boolean variable. if true, the document is also returned
     along with the metadata.
     """
+    # XXX - refactor to use the binary provided by erp5 buildout
+    command = ["pdfinfo", self.document.getUrl()]
+    stdout, stderr = Popen(command,
+                           stdout=PIPE,
+                           stderr=PIPE).communicate()
+    info_list = filter(None, stdout.split("\n"))
+    metadata = {}
+    for info in iter(info_list):
+      if info.count(":") == 1:
+        info_name, info_value = info.split(":")
+      else:
+        info_name, info_value = info.split("  ")
+        info_name = info_name.replace(":", "")
+      info_value = info_value.strip()
+      metadata[info_name.lower()] = info_value
+    return metadata
 
   def setMetadata(self, metadata):
     """Returns a document with new metadata.

Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/testPDFHandler.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/testPDFHandler.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/testPDFHandler.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/testPDFHandler.py [utf8] Sun Feb 20 20:31:57 2011
@@ -29,17 +29,28 @@
 
 import unittest
 from cloudooo.handler.pdf.handler import PDFHandler
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from types import DictType
 
 
-class TestPDFHandler(unittest.TestCase):
+class TestPDFHandler(HandlerTestCase):
 
   def testConvertPDFtoText(self):
     """Test conversion of pdf to txt"""
     pdf_document = open("data/test.pdf").read()
-    handler = PDFHandler("/tmp/", pdf_document, "pdf")
+    handler = PDFHandler(self.tmp_url, pdf_document, "pdf")
     txt_document = handler.convert("txt")
     self.assertTrue(txt_document.startswith("UNG Docs Architecture"))
 
+  def testgetMetadata(self):
+    """Test if the metadata are extracted correctly"""
+    pdf_document = open("data/test.pdf").read()
+    handler = PDFHandler(self.tmp_url, pdf_document, "pdf")
+    metadata = handler.getMetadata()
+    self.assertEquals(type(metadata), DictType)
+    self.assertNotEquals(metadata, {})
+    self.assertEquals(metadata["title"], 'Free Cloud Alliance Presentation')
+
 
 def test_suite():
   suite = unittest.TestSuite() 

Added: erp5/trunk/utils/cloudooo/cloudooo/handler/tests/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/tests/__init__.py?rev=43500&view=auto
==============================================================================
    (empty)

Added: erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py?rev=43500&view=auto
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py (added)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py [utf8] Sun Feb 20 20:31:57 2011
@@ -0,0 +1,64 @@
+##############################################################################
+#
+# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
+#                    Gabriel M. Monnerat <gabriel at tiolive.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility 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
+# guarantees 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 os import environ, path
+from ConfigParser import ConfigParser
+import sys
+
+config = ConfigParser()
+
+def check_folder(working_path, tmp_dir_path):
+  if not path.exists(working_path):
+    mkdir(working_path)
+  if not path.exists(tmp_dir_path):
+    mkdir(tmp_dir_path)
+
+class HandlerTestCase(unittest.TestCase):
+  """Test Case to load cloudooo conf."""
+
+  def setUp(self):
+    """Creates a environment to run the tests. Is called always before the
+    tests."""
+    server_cloudooo_conf = environ.get("server_cloudooo_conf", None)
+    if server_cloudooo_conf is not None:
+      config.read(server_cloudooo_conf)
+    self.hostname = config.get("server:main", "host")
+    self.cloudooo_port = config.get("server:main", "port")
+    self.openoffice_port = config.get("app:main", "openoffice_port")
+    self.office_binary_path = config.get("app:main", "office_binary_path")
+    self.python_path = sys.executable
+    self.working_path = config.get("app:main", "working_path")
+    self.tmp_url = path.join(self.working_path, "tmp")
+    check_folder(self.working_path, self.tmp_url)
+    self.uno_path = config.get("app:main", "uno_path")
+    self.afterSetUp()
+
+  def afterSetUp(self):
+    """ """

Modified: erp5/trunk/utils/cloudooo/cloudooo/paster_application.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/paster_application.py?rev=43500&r1=43499&r2=43500&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/paster_application.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/paster_application.py [utf8] Sun Feb 20 20:31:57 2011
@@ -67,7 +67,6 @@ def application(global_config, **local_c
         if current_value:
           value = '%s:%s' % (value, current_value)
       environment_dict[variable_name] = value
-
   gc.enable()
   debug_mode = convertStringToBool(local_config.get('debug_mode'))
   configureLogger(debug_mode=debug_mode)



More information about the Erp5-report mailing list