Source code for odoo_xmlrpc_twisted.test.test_create_product
"""test program for module :func:`odoo_xmlrpc_twisted.functions.create_product`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_productimportsupport_create_product# ------- 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 partner idcustom_partner_id=config.get('get_settings_customer','partner_id')# get the dedicated image namecustom_image_name=config.get('get_settings_product','image_name')
[docs]classtest_create_product(OdooTestCase):""" Class for the test cases of the module "create_product" """
[docs]deftest_cases(self):""" test cases of the module "create_product" """product_id=support_create_product(custom_partner_id,custom_image_name)# Register created product for automatic cleanupifproduct_id:self.addCleanup_product(product_id)self.assertTrue(product_id)