diff --git a/openerp/tests/__init__.py b/openerp/tests/__init__.py new file mode 100644 index 00000000000..3b2dcd15af3 --- /dev/null +++ b/openerp/tests/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +import unittest2 + +import test_orm +import test_ir_sequence +import test_xmlrpc + +def make_suite(): + suite = unittest2.TestSuite() + suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_ir_sequence)) + suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_orm)) + return suite + +def make_suite_no_db(): + suite = unittest2.TestSuite() + suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_xmlrpc)) + return suite + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/tests/addons/test_exceptions/__init__.py b/openerp/tests/addons/test_exceptions/__init__.py similarity index 100% rename from tests/addons/test_exceptions/__init__.py rename to openerp/tests/addons/test_exceptions/__init__.py diff --git a/tests/addons/test_exceptions/__openerp__.py b/openerp/tests/addons/test_exceptions/__openerp__.py similarity index 100% rename from tests/addons/test_exceptions/__openerp__.py rename to openerp/tests/addons/test_exceptions/__openerp__.py diff --git a/tests/addons/test_exceptions/models.py b/openerp/tests/addons/test_exceptions/models.py similarity index 100% rename from tests/addons/test_exceptions/models.py rename to openerp/tests/addons/test_exceptions/models.py diff --git a/tests/addons/test_exceptions/view.xml b/openerp/tests/addons/test_exceptions/view.xml similarity index 100% rename from tests/addons/test_exceptions/view.xml rename to openerp/tests/addons/test_exceptions/view.xml diff --git a/tests/common.py b/openerp/tests/common.py similarity index 85% rename from tests/common.py rename to openerp/tests/common.py index 3de65489587..57ebead925e 100644 --- a/tests/common.py +++ b/openerp/tests/common.py @@ -6,9 +6,10 @@ import xmlrpclib import openerp -ADDONS_PATH = os.environ['OPENERP_ADDONS_PATH'] -PORT = int(os.environ['OPENERP_PORT']) -DB = os.environ['OPENERP_DATABASE'] +# The openerp library is supposed already configured. +ADDONS_PATH = openerp.tools.config['addons_path'] +PORT = openerp.tools.config['xmlrpc_port'] +DB = openerp.tools.config['db_name'] HOST = '127.0.0.1' @@ -25,15 +26,19 @@ db_proxy_61 = None model_proxy_61 = None model_uri_61 = None -def setUpModule(): +def start_openerp(): """ - Start the OpenERP server similary to the openerp-server script and - setup some xmlrpclib proxies. + Start the OpenERP server similary to the openerp-server script. """ - openerp.tools.config['addons_path'] = ADDONS_PATH - openerp.tools.config['xmlrpc_port'] = PORT openerp.service.start_services() + # Ugly way to ensure the server is listening. + time.sleep(2) + +def create_xmlrpc_proxies(): + """ + setup some xmlrpclib proxies. + """ global common_proxy_60 global db_proxy_60 global object_proxy_60 @@ -55,9 +60,6 @@ def setUpModule(): db_proxy_61 = xmlrpclib.ServerProxy(model_uri_61 + 'db') model_proxy_61 = xmlrpclib.ServerProxy(model_uri_61 + 'model/' + DB) - # Ugly way to ensure the server is listening. - time.sleep(2) - def tearDownModule(): """ Shutdown the OpenERP server similarly to a single ctrl-c. """ openerp.service.stop_services() diff --git a/tests/test_ir_sequence.py b/openerp/tests/test_ir_sequence.py similarity index 99% rename from tests/test_ir_sequence.py rename to openerp/tests/test_ir_sequence.py index 263710cbd3b..c926a52ed64 100644 --- a/tests/test_ir_sequence.py +++ b/openerp/tests/test_ir_sequence.py @@ -19,7 +19,9 @@ import common DB = common.DB ADMIN_USER_ID = common.ADMIN_USER_ID -setUpModule = common.setUpModule +def setUpModule(): + common.create_xmlrpc_proxies() + tearDownModule = common.tearDownModule def registry(model): diff --git a/tests/test_orm.py b/openerp/tests/test_orm.py similarity index 98% rename from tests/test_orm.py rename to openerp/tests/test_orm.py index 0dfed0005cb..c11d4cd19d2 100644 --- a/tests/test_orm.py +++ b/openerp/tests/test_orm.py @@ -1,9 +1,10 @@ import os import unittest2 + import openerp UID = 1 -DB = os.environ['OPENERP_DATABASE'] +DB = openerp.tools.config['db_name'] CREATE = lambda values: (0, False, values) UPDATE = lambda id, values: (1, id, values) @@ -13,14 +14,13 @@ LINK_TO = lambda id: (4, id, False) DELETE_ALL = lambda: (5, False, False) REPLACE_WITH = lambda ids: (6, False, ids) -def setUpModule(): - openerp.tools.config['addons_path'] = os.environ['OPENERP_ADDONS_PATH'] - class TestO2MSerialization(unittest2.TestCase): + def setUp(self): self.cr = openerp.modules.registry.RegistryManager.get(DB).db.cursor() self.partner = openerp.modules.registry.RegistryManager.get(DB)['res.partner'] self.address = openerp.modules.registry.RegistryManager.get(DB)['res.partner.address'] + def tearDown(self): self.cr.rollback() self.cr.close() diff --git a/tests/test_xmlrpc.py b/openerp/tests/test_xmlrpc.py similarity index 96% rename from tests/test_xmlrpc.py rename to openerp/tests/test_xmlrpc.py index 3f7286cfab1..65d40af866a 100644 --- a/tests/test_xmlrpc.py +++ b/openerp/tests/test_xmlrpc.py @@ -19,7 +19,10 @@ ADMIN_USER = common.ADMIN_USER ADMIN_USER_ID = common.ADMIN_USER_ID ADMIN_PASSWORD = common.ADMIN_PASSWORD -setUpModule = common.setUpModule +def setUpModule(): + common.start_openerp() + common.create_xmlrpc_proxies() + tearDownModule = common.tearDownModule class test_xmlrpc(unittest2.TestCase): diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index ec2b8de39b1..00000000000 --- a/tests/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -import test_xmlrpc - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: