From d85da033148afa707577dcf65dd9a719c064d0d1 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 1 Mar 2012 11:54:19 +0100 Subject: [PATCH] [IMP] tests: xml-rpc test drops the created database (which has its own name, not clashing with the main db name). bzr revid: vmt@openerp.com-20120301105419-8ik3z5eikwjnackk --- openerp/service/__init__.py | 2 ++ openerp/tests/__init__.py | 6 ++---- openerp/tests/common.py | 8 ++++++++ openerp/tests/test_xmlrpc.py | 20 +++++++++++++++----- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/openerp/service/__init__.py b/openerp/service/__init__.py index c387d272e26..511d62c5862 100644 --- a/openerp/service/__init__.py +++ b/openerp/service/__init__.py @@ -48,6 +48,8 @@ import openerp.wsgi _logger = logging.getLogger(__name__) +# TODO block until the server is really up, accepting connections +# TODO be idemptotent (as long as stop_service was not called). def start_services(): """ Start all services. diff --git a/openerp/tests/__init__.py b/openerp/tests/__init__.py index de3bf5ea914..e528da6ba08 100644 --- a/openerp/tests/__init__.py +++ b/openerp/tests/__init__.py @@ -10,15 +10,13 @@ See the :ref:`test-framework` section in the :ref:`features` list. import test_orm import test_ir_sequence -import test_xmlrpc fast_suite = [ - test_xmlrpc, # Creates a database - test_ir_sequence, # Assume an existing database + test_ir_sequence, ] checks = [ - test_orm, # Assume an existing database + test_orm, ] # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/tests/common.py b/openerp/tests/common.py index 5b1b8096edf..fdbb83f6b5b 100644 --- a/openerp/tests/common.py +++ b/openerp/tests/common.py @@ -74,4 +74,12 @@ class RpcCase(unittest2.TestCase): self.proxy.db_61 = xmlrpclib.ServerProxy(url_61 + 'db') self.proxy.model_61 = xmlrpclib.ServerProxy(url_61 + 'model/' + DB) + @classmethod + def generate_database_name(cls): + if hasattr(cls, '_database_id'): + cls._database_id += 1 + else: + cls._database_id = 0 + return '_fresh_name_' + str(cls._database_id) + '_' + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/tests/test_xmlrpc.py b/openerp/tests/test_xmlrpc.py index dfed851dbe3..37655e72718 100644 --- a/openerp/tests/test_xmlrpc.py +++ b/openerp/tests/test_xmlrpc.py @@ -13,12 +13,15 @@ import xmlrpclib import openerp import common -DB = common.DB +DB = None ADMIN_USER = common.ADMIN_USER ADMIN_USER_ID = common.ADMIN_USER_ID ADMIN_PASSWORD = common.ADMIN_PASSWORD -setUpModule = common.start_openerp +def setUpModule(): + common.start_openerp() + global DB + DB = common.RpcCase.generate_database_name() tearDownModule = common.stop_openerp @@ -29,8 +32,8 @@ class test_xmlrpc(common.RpcCase): Simulate a OpenERP client requesting the creation of a database and polling the server until the creation is complete. """ - progress_id = self.proxy.db_60.create(ADMIN_PASSWORD, DB, True, - False, ADMIN_PASSWORD) + progress_id = self.proxy.db_60.create(ADMIN_PASSWORD,DB, True, False, + ADMIN_PASSWORD) while True: time.sleep(1) progress, users = self.proxy.db_60.get_progress(ADMIN_PASSWORD, @@ -55,12 +58,19 @@ class test_xmlrpc(common.RpcCase): def test_xmlrpc_61_ir_model_search(self): """ Try a search on the object service. """ - proxy = xmlrpclib.ServerProxy(self.proxy.url_61 + 'model/' + DB + '/ir.model') + proxy = xmlrpclib.ServerProxy(self.proxy.url_61 + 'model/' + DB + + '/ir.model') ids = proxy.execute(ADMIN_USER_ID, ADMIN_PASSWORD, 'search', []) assert ids ids = proxy.execute(ADMIN_USER_ID, ADMIN_PASSWORD, 'search', [], {}) assert ids + def test_zz_xmlrpc_drop_database(self): + """ + Simulate a OpenERP client requesting the deletion of a database. + """ + assert self.proxy.db_60.drop(ADMIN_PASSWORD, DB) is True + if __name__ == '__main__': unittest2.main()