Commit ca7ec501 authored by Gabriel Monnerat's avatar Gabriel Monnerat

- remove not used imports

- add script to run cloudooo tests. This script will replace the buildout template used to run cloudooo tests.
- remove obsolete script


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@40333 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b8ea53d9
...@@ -35,7 +35,6 @@ from os import environ, path ...@@ -35,7 +35,6 @@ from os import environ, path
from interfaces.mimemapper import IMimemapper from interfaces.mimemapper import IMimemapper
from types import InstanceType from types import InstanceType
from utils import getCleanPythonEnvironment from utils import getCleanPythonEnvironment
from sys import executable as python_path
class MimeMapper(object): class MimeMapper(object):
"""Load all filters from OOo. You can get the of the filter you want or all """Load all filters from OOo. You can get the of the filter you want or all
......
#!/usr/bin/env python
import sys
import unittest
from getopt import getopt, GetoptError
from time import sleep
from cloudooo.utils import socketStatus
from ConfigParser import ConfigParser
from os import chdir, path
from subprocess import Popen
ENVIRONMENT_PATH = path.abspath(path.dirname(__file__))
def wait_liberate_port(hostname, port):
for n in range(timeout_limit):
if not socketStatus(hostname, port):
break
sleep(1)
def wait_use_port(hostname, port):
for n in range(timeout_limit):
if socketStatus(hostname, port):
return
sleep(1)
def get_partial_log():
if path.exists(log_path):
return '\n'.join(open(log_path).read().split('\n')[-30:])
return ''
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():
DAEMON = OPENOFFICE = XVFB = False
test_name = sys.argv[-1]
if not path.exists(path.join(ENVIRONMENT_PATH, '%s.py' % test_name)):
exit("%s not exists\n" % test_name)
try:
opt_list, arg_list = getopt(sys.argv[1:-1], "", ["with-daemon",
"with-openoffice",
"with-xvfb",
"log_path=",
"cloudooo_runner=",
"server_cloudooo_conf=",
"timeout_limit="])
except GetoptError, msg:
exit(msg.msg)
for opt, arg in opt_list:
if opt == "--with-daemon":
DAEMON = True
elif opt == "--with-openoffice":
OPENOFFICE = True
elif opt == "--with-xvfb":
XVFB = True
elif opt == "--log_path":
log_path = arg
elif opt == "--cloudooo_runner":
cloudooo_runner = arg
elif opt == "--server_cloudooo_conf":
server_cloudooo_conf = arg
elif opt == "--timeout_limit":
timeout_limit = arg
from cloudoooTestCase import loadConfig, startFakeEnvironment, stopFakeEnvironment
sys.path.append(ENVIRONMENT_PATH)
chdir(ENVIRONMENT_PATH)
config = ConfigParser()
config.read(server_cloudooo_conf)
openoffice_port = int(config.get("app:main", "openoffice_port"))
xvfb_port = int(config.get("app:main", "virtual_display_port"))
xvfb_display_id = int(config.get("app:main", "virtual_display_id"))
hostname = config.get("app:main", "application_hostname")
server_port = int(config.get("server:main", "port"))
run_dir = config.get('app:main', 'working_path')
test_name = sys.argv[-1]
if not path.exists(path.join(ENVIRONMENT_PATH, '%s.py' % test_name)):
exit("%s not exists\n" % test_name)
if DAEMON:
loadConfig(server_cloudooo_conf)
Popen([cloudooo_runner, 'start']).communicate()
wait_use_port(hostname, server_port)
print get_partial_log()
try:
run_test(test_name)
finally:
Popen([cloudooo_runner, 'stop']).communicate()
wait_liberate_port(hostname, server_port)
elif OPENOFFICE:
openoffice, xvfb = startFakeEnvironment(conf_path=server_cloudooo_conf)
run_test(test_name)
stopFakeEnvironment()
elif XVFB:
xvfb = startFakeEnvironment(start_openoffice=False,
conf_path=server_cloudooo_conf)
run_test(test_name)
stopFakeEnvironment(stop_openoffice=False)
else:
loadConfig(server_cloudooo_conf)
run_test(test_name)
if __name__ == "__main__":
run()
##############################################################################
#
# Copyright (c) 2002-2010 Nexedi SA and Contributors. All Rights Reserved.
# Gabriel M. Monnerat <gabriel@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 os
import unittest
from cloudoooTestCase import startFakeEnvironment, stopFakeEnvironment
TestRunner = unittest.TextTestRunner
suite = unittest.TestSuite()
tests = os.listdir(os.curdir)
tests = [n[:-3] for n in tests if n.startswith('test') and n.endswith('.py')]
for test in tests:
m = __import__(test)
if hasattr(m, 'test_suite'):
suite.addTest(m.test_suite())
if __name__ == '__main__':
startFakeEnvironment()
TestRunner(verbosity=2).run(suite)
stopFakeEnvironment()
...@@ -316,7 +316,6 @@ class TestServer(cloudoooTestCase): ...@@ -316,7 +316,6 @@ class TestServer(cloudoooTestCase):
"""Test to verify if the behavior of server is normal when a empty string """Test to verify if the behavior of server is normal when a empty string
is sent""" is sent"""
data = encodestring("") data = encodestring("")
error_msg = "This document can not be loaded or is empty\n"
fail_msg = "This document can not be loaded, it is empty\n" fail_msg = "This document can not be loaded, it is empty\n"
try: try:
self.proxy.convertFile(data, '', '') self.proxy.convertFile(data, '', '')
......
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