Source code for odoo_xmlrpc_twisted.test.test_create_user
"""test program for module :func:`odoo_xmlrpc_twisted.functions.create_user`based on the "unittest" functionality"""importunittestimportosimportsysimportconfigparser# Import base test case for automatic cleanupfromodoo_xmlrpc_twisted.test.base_test_caseimportOdooTestCase# as this program is in the folder "test",# import the module to test from the subdirectory "support"current=os.path.dirname(os.path.realpath(__file__))parent_directory=os.path.dirname(current)sys.path.append(parent_directory+'/support')fromsupport_create_userimportsupport_create_user# ------- get parameter from the settings file "parameter_test.ini"# Name and full path of the "ini" filefilename="parameter_test.ini"# Get the parent directory (repo root) and navigate to config foldercurrent_dir=os.path.dirname(os.path.abspath(__file__))parent_dir=os.path.dirname(current_dir)config_dir=os.path.join(parent_dir,'config')fullpath=os.path.join(config_dir,filename)config=configparser.ConfigParser()config.read(fullpath)# get the dedicated email of the customer to be createdcustom_new_email=config.get('get_settings_customer','new_email')# get the dedicated password of the customercustom_password=config.get('get_settings_customer','password')
[docs]classtest_create_user(OdooTestCase):""" Class for the test cases of the module "create_user" """
[docs]deftest_cases(self):""" test cases of the module "create_user" """result,user_id,partner_id=support_create_user(custom_new_email,custom_new_email,custom_new_email,custom_password)# Register created resources for automatic cleanup# Note: addCleanup runs in LIFO order, so register partner FIRST (deleted LAST)ifpartner_id:self.addCleanup_partner(partner_id)ifuser_id:self.addCleanup_user(user_id)self.assertEqual(result,'True')