Commit b10c46b5 authored by Nicolas Delaby's avatar Nicolas Delaby

Move some constant definition from options of test execution, to

test modules.
because each test suite defined in a test module can not work
if the constant is False. ie Constant are not Optional.
As an example:
 runCloudOOoUnitTest --with-deamon conf_path testServer.py
can not work without --with-deamon option, so move this flag to testServer.py



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@42069 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 904b2c40
......@@ -30,30 +30,10 @@ def exit(msg):
sys.stderr.write(msg)
sys.exit(0)
def run_test(test_name):
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())
TestRunner(verbosity=2).run(suite)
def run():
parser = ArgumentParser(description="Unit Test Runner for Cloudooo")
parser.add_argument('server_cloudooo_conf')
parser.add_argument('test_name')
parser.add_argument('--with-daemon', dest='DAEMON',
action='store_true',
help="it starts the cloudooo daemon")
parser.add_argument('--with-openoffice', dest='OPENOFFICE',
action='store_true',
help="it starts one Xvfb and one OpenOffice")
parser.add_argument('--with-xvfb', dest='XVFB',
action='store_true',
help="it starts one Xvfb only")
parser.add_argument('--timeout_limit', dest='timeout_limit',
type=long, default=30,
help="Timeout to waiting for the cloudooo stop")
......@@ -67,10 +47,7 @@ def run():
if server_cloudooo_conf.startswith(curdir):
server_cloudooo_conf = path.join(path.abspath(curdir),
server_cloudooo_conf)
DAEMON = namespace.DAEMON
OPENOFFICE = namespace.OPENOFFICE
XVFB = namespace.XVFB
environ['server_cloudooo_conf'] = server_cloudooo_conf
paster_path = namespace.paster_path
python_extension = '.py'
......@@ -92,15 +69,27 @@ def run():
hostname = config.get("app:main", "application_hostname")
server_port = int(config.get("server:main", "port"))
run_dir = config.get('app:main', 'working_path')
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)
XVFB = getattr(module, 'XVFB', False)
TestRunner = unittest.TextTestRunner
suite = unittest.TestSuite()
suite.addTest(module.test_suite())
if DAEMON:
loadConfig(server_cloudooo_conf)
command = [paster_path, "serve", server_cloudooo_conf]
process = Popen(command)
wait_use_port(hostname, openoffice_port)
wait_use_port(hostname, server_port)
chdir(ENVIRONMENT_PATH)
try:
run_test(test_name)
TestRunner(verbosity=2).run(suite)
finally:
process.send_signal(1)
wait_liberate_port(hostname, server_port)
......@@ -110,7 +99,7 @@ def run():
chdir(ENVIRONMENT_PATH)
openoffice, xvfb = startFakeEnvironment(conf_path=server_cloudooo_conf)
try:
run_test(test_name)
TestRunner(verbosity=2).run(suite)
finally:
stopFakeEnvironment()
elif XVFB:
......@@ -118,13 +107,12 @@ def run():
xvfb = startFakeEnvironment(start_openoffice=False,
conf_path=server_cloudooo_conf)
try:
run_test(test_name)
TestRunner(verbosity=2).run(suite)
finally:
stopFakeEnvironment(stop_openoffice=False)
else:
chdir(ENVIRONMENT_PATH)
loadConfig(server_cloudooo_conf)
run_test(test_name)
TestRunner(verbosity=2).run(suite)
if __name__ == "__main__":
run()
......@@ -32,6 +32,7 @@ from subprocess import Popen, PIPE
from base64 import encodestring, decodestring
from cloudoooTestCase import CloudoooTestCase, make_suite
DAEMON = True
class TestAllFormats(CloudoooTestCase):
"""Test XmlRpc Server. Needs cloudooo server started"""
......
......@@ -34,6 +34,7 @@ from base64 import encodestring, decodestring
from multiprocessing import Process
from cloudoooTestCase import CloudoooTestCase, make_suite
DAEMON = True
class TestHighLoad(CloudoooTestCase):
"""Test with many simultaneous connection"""
......
......@@ -168,6 +168,7 @@ chart_expected_tuple = (('sds', 'StarChart 3.0'),
('sxs', 'OpenOffice.org 1.0 Chart'),
('odc', 'ODF Chart'))
OPENOFFICE = True
class TestMimeMapper(CloudoooTestCase):
"""Test if object load filters correctly of OOo."""
......
......@@ -32,6 +32,7 @@ from cloudoooTestCase import CloudoooTestCase, make_suite
from cloudooo.handler.ooo.monitor.request import MonitorRequest
from cloudooo.handler.ooo.monitor.memory import MonitorMemory
OPENOFFICE = True
class TestMonitorInit(CloudoooTestCase):
"""Test Case to test if the monitors are controlled correctly"""
......
......@@ -34,6 +34,7 @@ from psutil import Process
from types import IntType
from cloudoooTestCase import make_suite
OPENOFFICE = True
class TestMonitorMemory(unittest.TestCase):
"""Test case to see if the MonitorMemory is properly managing the
......
......@@ -32,6 +32,7 @@ from cloudooo.handler.ooo.monitor.request import MonitorRequest
from cloudoooTestCase import CloudoooTestCase, make_suite
from cloudooo.handler.ooo.application.openoffice import openoffice
OPENOFFICE = True
class TestMonitorRequest(CloudoooTestCase):
"""Test all features of a monitor following the interface"""
......
......@@ -32,6 +32,7 @@ from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.monitor.timeout import MonitorTimeout
from cloudoooTestCase import make_suite
OPENOFFICE = True
class TestMonitorTimeout(unittest.TestCase):
"""Test all features of a monitor following the interface"""
......
......@@ -38,6 +38,7 @@ import os
from lxml import etree
from zipfile import ZipFile
OPENOFFICE = True
class TestOOHandler(CloudoooTestCase):
"""Test OOHandler and manipulation of OOo Instance"""
......
......@@ -32,6 +32,7 @@ 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):
"""Test OpenOffice object and manipulation of OOo Instance"""
......
......@@ -36,6 +36,7 @@ from cloudoooTestCase import CloudoooTestCase, make_suite
from zipfile import ZipFile, is_zipfile
from types import DictType
DAEMON = True
class TestServer(CloudoooTestCase):
"""Test XmlRpc Server. Needs cloudooo server started"""
......
......@@ -35,6 +35,7 @@ from cloudoooTestCase import CloudoooTestCase, make_suite
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.document import FileSystemDocument
OPENOFFICE = True
class TestUnoConverter(CloudoooTestCase):
"""Test case to test all features of the unoconverter script"""
......
......@@ -34,6 +34,7 @@ from subprocess import Popen, PIPE
from os import environ, path
from cloudoooTestCase import CloudoooTestCase, make_suite
OPENOFFICE = True
class TestUnoMimeMapper(CloudoooTestCase):
"""Test Case to test all features of script unomimemapper"""
......
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