[IMP] tests: moved tests into openerp.tests, expose test suites.

bzr revid: vmt@openerp.com-20111201140012-y9kmto0le0ugxdzf
This commit is contained in:
Vo Minh Thu
2011-12-01 15:00:12 +01:00
parent 596b904c51
commit 43745c4cb9
10 changed files with 43 additions and 21 deletions
+19
View File
@@ -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:
+13 -11
View File
@@ -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()
@@ -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):
@@ -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()
@@ -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):
-4
View File
@@ -1,4 +0,0 @@
# -*- coding: utf-8 -*-
import test_xmlrpc
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: