[Erp5-report] r43560 gabriel - in /erp5/trunk/utils/cloudooo/cloudooo/handler: ffmpeg/tests...
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Feb 22 14:39:40 CET 2011
Author: gabriel
Date: Tue Feb 22 14:39:40 2011
New Revision: 43560
URL: http://svn.erp5.org?rev=43560&view=rev
Log:
refactor and removed the duplicated code in handler test cases.
Added:
erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py
Removed:
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/cloudoooTestCase.py
Modified:
erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/runFFMPEGHandlerUnitTest.py
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/handler.py
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.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/testApplication.py
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFileSystemDocument.py
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFilter.py
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testHighLoad.py
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testInterface.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/testMonitorMemory.py
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorRequest.py
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorTimeout.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/ooo/tests/testUtils.py
erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/runPDFHandlerUnitTest.py
erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/runFFMPEGHandlerUnitTest.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/runFFMPEGHandlerUnitTest.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/runFFMPEGHandlerUnitTest.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ffmpeg/tests/runFFMPEGHandlerUnitTest.py [utf8] Tue Feb 22 14:39:40 2011
@@ -1,54 +1,34 @@
#!/usr/bin/env python
+##############################################################################
+#
+# Copyright (c) 2009-2011 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 sys
-import unittest
-from argparse import ArgumentParser
-from os import path, curdir, environ, chdir
+from cloudooo.handler.tests import runHandlerUnitTest
-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()
+ runHandlerUnitTest.run("ffmpeg")
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/handler.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/handler.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/handler.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/handler.py [utf8] Tue Feb 22 14:39:40 2011
@@ -195,8 +195,6 @@ class OOHandler:
if metadata.get("Data"):
self.document.reload(metadata['Data'])
metadata['Data'] = self.document.getContent()
- else:
- metadata['Data'] = ''
self.document.trash()
return metadata
Removed: 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=43559&view=auto
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/cloudoooTestCase.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/cloudoooTestCase.py (removed)
@@ -1,97 +0,0 @@
-##############################################################################
-#
-# 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
-import sys
-from os import path
-from os import environ, putenv
-from cloudooo.handler.ooo.application.openoffice import openoffice
-from cloudooo.handler.ooo.mimemapper import mimemapper
-from cloudooo.handler.tests.handlerTestCase import config, check_folder
-
-testcase_path = path.dirname(__file__)
-
-
-def make_suite(test_case):
- """Function is used to run all tests together"""
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(test_case))
- return suite
-
-
-def startFakeEnvironment(start_openoffice=True, conf_path=None):
- """Create a fake environment"""
-
- config.read(conf_path)
- uno_path = config.get("app:main", "uno_path")
- working_path = config.get("app:main", "working_path")
- hostname = config.get("server:main", "host")
- openoffice_port = int(config.get("app:main", "openoffice_port"))
- office_binary_path = config.get("app:main", "office_binary_path")
- tmp_dir = path.join(working_path, 'tmp')
- check_folder(working_path, tmp_dir)
- if not environ.get('uno_path'):
- environ['uno_path'] = uno_path
- office_binary_path = config.get("app:main", "office_binary_path")
- if not environ.get('office_binary_path'):
- environ['office_binary_path'] = office_binary_path
-
- if uno_path not in sys.path:
- sys.path.append(uno_path)
-
- fundamentalrc_file = '%s/fundamentalrc' % office_binary_path
- if path.exists(fundamentalrc_file) and \
- 'URE_BOOTSTRAP' not in environ:
- putenv('URE_BOOTSTRAP', 'vnd.sun.star.pathname:%s' % fundamentalrc_file)
-
- if start_openoffice:
- default_language = config.get('app:main',
- 'openoffice_user_interface_language', False,
- {'openoffice_user_interface_language': 'en'})
- openoffice.loadSettings(hostname,
- openoffice_port,
- working_path,
- office_binary_path,
- uno_path,
- default_language)
- openoffice.start()
- openoffice.acquire()
- hostname, port = openoffice.getAddress()
- kw = dict(uno_path=config.get("app:main", "uno_path"),
- office_binary_path=config.get("app:main", "office_binary_path"))
- if not mimemapper.isLoaded():
- mimemapper.loadFilterList(hostname, port, **kw)
- openoffice.release()
- return openoffice
-
-
-def stopFakeEnvironment(stop_openoffice=True):
- """Stop Openoffice """
- if stop_openoffice:
- openoffice.stop()
- return True
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.py [utf8] Tue Feb 22 14:39:40 2011
@@ -1,101 +1,33 @@
#!/usr/bin/env python
+##############################################################################
+#
+# 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 sys
-import unittest
-from argparse import ArgumentParser
-from time import sleep
-from subprocess import Popen
-from ConfigParser import ConfigParser
-from os import chdir, path, environ, curdir, remove
-from psutil import Process
-from signal import SIGQUIT
-
-ENVIRONMENT_PATH = path.abspath(path.dirname(__file__))
-
-
-def wait_use_port(pid, timeout_limit=30):
- process = Process(pid)
- for n in range(timeout_limit):
- if len(process.get_connections()) > 0:
- return True
- sleep(1)
- return False
-
-
-def exit(msg):
- sys.stderr.write(msg)
- sys.exit(0)
-
+from cloudooo.handler.tests import runHandlerUnitTest
def run():
- parser = ArgumentParser(description="Unit Test Runner for Cloudooo")
- parser.add_argument('server_cloudooo_conf')
- parser.add_argument('test_name')
- parser.add_argument('--timeout_limit', dest='timeout_limit',
- type=long, default=30,
- help="Timeout to waiting for the cloudooo stop")
- 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
- paster_path = namespace.paster_path
-
- 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)
-
- from cloudoooTestCase import startFakeEnvironment, stopFakeEnvironment
-
- sys.path.append(ENVIRONMENT_PATH)
-
- config = ConfigParser()
- config.read(server_cloudooo_conf)
- module = __import__(test_name)
- if not hasattr(module, "test_suite"):
- exit("No test suite to run, exiting immediately")
-
- DAEMON = getattr(module, 'DAEMON', False)
- OPENOFFICE = getattr(module, 'OPENOFFICE', False)
-
- TestRunner = unittest.TextTestRunner
- suite = unittest.TestSuite()
- suite.addTest(module.test_suite())
-
- if DAEMON:
- log_file = '%s/cloudooo_test.log' % config.get('app:main',
- 'working_path')
- if path.exists(log_file):
- remove(log_file)
- command = [paster_path, 'serve', '--log-file', log_file,
- server_cloudooo_conf]
- process = Popen(command)
- wait_use_port(process.pid)
- chdir(ENVIRONMENT_PATH)
- try:
- TestRunner(verbosity=2).run(suite)
- finally:
- process.send_signal(SIGQUIT)
- process.wait()
- elif OPENOFFICE:
- chdir(ENVIRONMENT_PATH)
- startFakeEnvironment(conf_path=server_cloudooo_conf)
- try:
- TestRunner(verbosity=2).run(suite)
- finally:
- stopFakeEnvironment()
- else:
- chdir(ENVIRONMENT_PATH)
- TestRunner(verbosity=2).run(suite)
-
-if __name__ == "__main__":
- run()
+ runHandlerUnitTest.run("ooo")
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -28,8 +28,7 @@
from xmlrpclib import ServerProxy, Fault
from base64 import encodestring, decodestring
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
import magic
file_detector = magic.Magic()
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -28,8 +28,7 @@
from xmlrpclib import ServerProxy, Fault
from base64 import encodestring, decodestring
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
import magic
file_detector = magic.Magic()
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testApplication.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testApplication.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testApplication.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testApplication.py [utf8] Tue Feb 22 14:39:40 2011
@@ -28,7 +28,7 @@
import unittest
from cloudooo.handler.ooo.application.application import Application
-from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import make_suite
class TestApplication(unittest.TestCase):
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFileSystemDocument.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFileSystemDocument.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFileSystemDocument.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFileSystemDocument.py [utf8] Tue Feb 22 14:39:40 2011
@@ -33,7 +33,7 @@ from base64 import decodestring
from os import path
from zipfile import ZipFile
from cloudooo.handler.ooo.document import FileSystemDocument
-from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import make_suite
class TestFileSystemDocument(unittest.TestCase):
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFilter.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFilter.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFilter.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testFilter.py [utf8] Tue Feb 22 14:39:40 2011
@@ -28,7 +28,6 @@
import unittest
from cloudooo.handler.ooo.filter import Filter
-from cloudoooTestCase import make_suite
class TestFilter(unittest.TestCase):
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -29,8 +29,7 @@
from xmlrpclib import ServerProxy
from base64 import encodestring, decodestring
from multiprocessing import Process, Array
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
import magic
DAEMON = True
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testInterface.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testInterface.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testInterface.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testInterface.py [utf8] Tue Feb 22 14:39:40 2011
@@ -46,8 +46,7 @@ from cloudooo.interfaces.monitor import
from cloudooo.interfaces.granulate import ITableGranulator, \
IImageGranulator, \
ITextGranulator
-from cloudoooTestCase import make_suite
-
+from cloudooo.handler.tests.handlerTestCase import make_suite
class TestInterface(unittest.TestCase):
"""Test All Interfaces"""
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -26,10 +26,9 @@
#
##############################################################################
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.mimemapper import MimeMapper
-from cloudoooTestCase import make_suite
text_expected_tuple = (
('doc', 'Microsoft Word 6.0'),
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -27,8 +27,7 @@
##############################################################################
import cloudooo.handler.ooo.monitor as monitor
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from cloudooo.handler.ooo.monitor.request import MonitorRequest
from cloudooo.handler.ooo.monitor.memory import MonitorMemory
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorMemory.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorMemory.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorMemory.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorMemory.py [utf8] Tue Feb 22 14:39:40 2011
@@ -32,7 +32,7 @@ from cloudooo.handler.ooo.application.op
from cloudooo.handler.ooo.monitor.memory import MonitorMemory
from psutil import Process
from types import IntType
-from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import make_suite
OPENOFFICE = True
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -28,8 +28,7 @@
from time import sleep
from cloudooo.handler.ooo.monitor.request import MonitorRequest
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from cloudooo.handler.ooo.application.openoffice import openoffice
OPENOFFICE = True
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorTimeout.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorTimeout.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorTimeout.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testMonitorTimeout.py [utf8] Tue Feb 22 14:39:40 2011
@@ -30,7 +30,7 @@ import unittest
from time import sleep
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.monitor.timeout import MonitorTimeout
-from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import make_suite
OPENOFFICE = True
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -30,8 +30,7 @@
from zipfile import ZipFile
from StringIO import StringIO
from lxml import etree
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from cloudooo.handler.ooo.granulator import OOGranulator
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -29,10 +29,9 @@
import magic
from os import path
from base64 import encodestring, decodestring
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from cloudooo.handler.ooo.handler import OOHandler
from cloudooo.handler.ooo.application.openoffice import openoffice
-from cloudoooTestCase import make_suite
import os
from lxml import etree
from zipfile import ZipFile
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -28,8 +28,7 @@
from zipfile import ZipFile
from lxml import etree
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from cloudooo.handler.ooo.document import OdfDocument
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -26,9 +26,8 @@
#
##############################################################################
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from cloudooo.handler.ooo.application.openoffice import OpenOffice
-from cloudoooTestCase import make_suite
from cloudooo.handler.ooo.utils.utils import waitStopDaemon
OPENOFFICE = True
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -30,8 +30,7 @@ from os.path import join, exists
from os import remove
from xmlrpclib import ServerProxy, Fault
from base64 import encodestring, decodestring
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from zipfile import ZipFile, is_zipfile
from types import DictType
import magic
@@ -308,8 +307,8 @@ class TestServer(HandlerTestCase):
def testConvertPyToPDF(self):
"""Test export python to pdf"""
- self._testConvertFile("cloudoooTestCase.py",
- join(self.tmp_url, "cloudoooTestCase.py"),
+ self._testConvertFile(__file__,
+ join(self.tmp_url, "output.py"),
'py',
'pdf',
'application/pdf')
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -31,8 +31,7 @@ import magic
import pkg_resources
from subprocess import Popen, PIPE
from os.path import exists, join
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.document import FileSystemDocument
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=43560&r1=43559&r2=43560&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] Tue Feb 22 14:39:40 2011
@@ -31,8 +31,7 @@ import pkg_resources
from cloudooo.handler.ooo.application.openoffice import openoffice
from subprocess import Popen, PIPE
from os import environ, path
-from cloudoooTestCase import make_suite
-from cloudooo.handler.tests.handlerTestCase import HandlerTestCase
+from cloudooo.handler.tests.handlerTestCase import HandlerTestCase, make_suite
OPENOFFICE = True
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUtils.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUtils.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUtils.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUtils.py [utf8] Tue Feb 22 14:39:40 2011
@@ -30,7 +30,7 @@ import unittest
import logging
from cloudooo.utils.utils import logger, configureLogger, \
convertStringToBool
-from cloudoooTestCase import make_suite
+from cloudooo.handler.tests.handlerTestCase import make_suite
class TestUtils(unittest.TestCase):
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/runPDFHandlerUnitTest.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/runPDFHandlerUnitTest.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/runPDFHandlerUnitTest.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/pdf/tests/runPDFHandlerUnitTest.py [utf8] Tue Feb 22 14:39:40 2011
@@ -1,54 +1,34 @@
#!/usr/bin/env python
+##############################################################################
+#
+# 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 sys
-import unittest
-from argparse import ArgumentParser
-from os import path, curdir, environ, chdir
+from cloudooo.handler.tests import runHandlerUnitTest
-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()
+ runHandlerUnitTest.run("pdf")
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py?rev=43560&r1=43559&r2=43560&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/tests/handlerTestCase.py [utf8] Tue Feb 22 14:39:40 2011
@@ -28,13 +28,21 @@
import unittest
-from os import environ, path, mkdir
-from ConfigParser import ConfigParser
import sys
+from os import environ, path, mkdir, putenv
+from ConfigParser import ConfigParser
+from cloudooo.handler.ooo.application.openoffice import openoffice
+from cloudooo.handler.ooo.mimemapper import mimemapper
config = ConfigParser()
+def make_suite(test_case):
+ """Function is used to run all tests together"""
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(test_case))
+ return suite
+
def check_folder(working_path, tmp_dir_path):
if not path.exists(working_path):
mkdir(working_path)
@@ -42,6 +50,58 @@ def check_folder(working_path, tmp_dir_p
mkdir(tmp_dir_path)
+def startFakeEnvironment(start_openoffice=True, conf_path=None):
+ """Create a fake environment"""
+
+ config.read(conf_path)
+ uno_path = config.get("app:main", "uno_path")
+ working_path = config.get("app:main", "working_path")
+ hostname = config.get("server:main", "host")
+ openoffice_port = int(config.get("app:main", "openoffice_port"))
+ office_binary_path = config.get("app:main", "office_binary_path")
+ tmp_dir = path.join(working_path, 'tmp')
+ check_folder(working_path, tmp_dir)
+ if not environ.get('uno_path'):
+ environ['uno_path'] = uno_path
+ office_binary_path = config.get("app:main", "office_binary_path")
+ if not environ.get('office_binary_path'):
+ environ['office_binary_path'] = office_binary_path
+
+ if uno_path not in sys.path:
+ sys.path.append(uno_path)
+
+ fundamentalrc_file = '%s/fundamentalrc' % office_binary_path
+ if path.exists(fundamentalrc_file) and \
+ 'URE_BOOTSTRAP' not in environ:
+ putenv('URE_BOOTSTRAP', 'vnd.sun.star.pathname:%s' % fundamentalrc_file)
+
+ if start_openoffice:
+ default_language = config.get('app:main',
+ 'openoffice_user_interface_language', False,
+ {'openoffice_user_interface_language': 'en'})
+ openoffice.loadSettings(hostname,
+ openoffice_port,
+ working_path,
+ office_binary_path,
+ uno_path,
+ default_language)
+ openoffice.start()
+ openoffice.acquire()
+ hostname, port = openoffice.getAddress()
+ kw = dict(uno_path=config.get("app:main", "uno_path"),
+ office_binary_path=config.get("app:main", "office_binary_path"))
+ if not mimemapper.isLoaded():
+ mimemapper.loadFilterList(hostname, port, **kw)
+ openoffice.release()
+ return openoffice
+
+
+def stopFakeEnvironment(stop_openoffice=True):
+ """Stop Openoffice """
+ if stop_openoffice:
+ openoffice.stop()
+ return True
+
class HandlerTestCase(unittest.TestCase):
"""Test Case to load cloudooo conf."""
Added: erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py?rev=43560&view=auto
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py (added)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/tests/runHandlerUnitTest.py [utf8] Tue Feb 22 14:39:40 2011
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+
+import sys
+from pkg_resources import resource_filename
+import unittest
+from time import sleep
+from subprocess import Popen
+from ConfigParser import ConfigParser
+from argparse import ArgumentParser
+from os import chdir, path, environ, curdir, remove
+from psutil import Process
+from signal import SIGQUIT
+
+
+def wait_use_port(pid, timeout_limit=30):
+ process = Process(pid)
+ for n in range(timeout_limit):
+ if len(process.get_connections()) > 0:
+ return True
+ sleep(1)
+ return False
+
+
+def exit(msg):
+ sys.stderr.write(msg)
+ sys.exit(0)
+
+
+def run(handler_name):
+ description = "Unit Test Runner for %s Handler" % handler_name.capitalize()
+ parser = ArgumentParser(description=description)
+ parser.add_argument('server_cloudooo_conf')
+ parser.add_argument('test_name')
+ parser.add_argument('--timeout_limit', dest='timeout_limit',
+ type=long, default=30,
+ help="Timeout to waiting for the cloudooo stop")
+ parser.add_argument('--paster_path', dest='paster_path',
+ default='paster',
+ help="Path to Paster script")
+ namespace = parser.parse_args()
+ environment_path = resource_filename("cloudooo",
+ "handler/%s/tests" % handler_name)
+ 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
+ paster_path = namespace.paster_path
+
+ 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)
+
+ from cloudooo.handler.tests.handlerTestCase import startFakeEnvironment, \
+ stopFakeEnvironment
+
+ sys.path.append(environment_path)
+
+ config = ConfigParser()
+ config.read(server_cloudooo_conf)
+ module = __import__(test_name)
+ if not hasattr(module, "test_suite"):
+ exit("No test suite to run, exiting immediately")
+
+ DAEMON = getattr(module, 'DAEMON', False)
+ OPENOFFICE = getattr(module, 'OPENOFFICE', False)
+
+ TestRunner = unittest.TextTestRunner
+ suite = unittest.TestSuite()
+ suite.addTest(module.test_suite())
+
+ if DAEMON:
+ log_file = '%s/cloudooo_test.log' % config.get('app:main',
+ 'working_path')
+ if path.exists(log_file):
+ remove(log_file)
+ command = [paster_path, 'serve', '--log-file', log_file,
+ server_cloudooo_conf]
+ process = Popen(command)
+ wait_use_port(process.pid)
+ chdir(environment_path)
+ try:
+ TestRunner(verbosity=2).run(suite)
+ finally:
+ process.send_signal(SIGQUIT)
+ process.wait()
+ elif OPENOFFICE:
+ chdir(environment_path)
+ startFakeEnvironment(conf_path=server_cloudooo_conf)
+ try:
+ TestRunner(verbosity=2).run(suite)
+ finally:
+ stopFakeEnvironment()
+ else:
+ chdir(environment_path)
+ TestRunner(verbosity=2).run(suite)
More information about the Erp5-report
mailing list