예제 #1
0
파일: testXHTML.py 프로젝트: Elbagoury/erp5
def addTestMethodDynamically(test_class, validator, target_business_templates):
  from Products.ERP5.tests.utils import BusinessTemplateInfoTar
  from Products.ERP5.tests.utils import BusinessTemplateInfoDir
  business_template_info_list = []

  for url, _ in ERP5TypeTestCase._getBTPathAndIdList(target_business_templates):
    if os.path.isdir(url):
      business_template_info = BusinessTemplateInfoDir(url)
    else:
      business_template_info = BusinessTemplateInfoTar(url)
    business_template_info_list.append(business_template_info)

  tested_portal_type_list = []
  for business_template_info in business_template_info_list:
    for module_id, module_portal_type in business_template_info.modules.items():
      portal_type_list = [module_portal_type, ] + \
            business_template_info.allowed_content_types.get(module_portal_type, [])
      portal_type_path_dict = dict(zip(portal_type_list, portal_type_list))
      testPortalTypeViewRecursivly(test_class=test_class,
                       validator=validator,
                       module_id=module_id,
                       business_template_info=business_template_info,
                       business_template_info_list=business_template_info_list,
                       portal_type_list=portal_type_list,
                       portal_type_path_dict=portal_type_path_dict,
                       base_path = '',
                       tested_portal_type_list=tested_portal_type_list)
예제 #2
0
def addTestMethodDynamically(test_class,
                             validator,
                             target_business_templates,
                             expected_failure_list=()):
    from Products.ERP5.tests.utils import BusinessTemplateInfoTar
    from Products.ERP5.tests.utils import BusinessTemplateInfoDir
    business_template_info_list = []

    for url, _ in ERP5TypeTestCase._getBTPathAndIdList(
            target_business_templates):
        if os.path.isdir(url):
            business_template_info = BusinessTemplateInfoDir(url)
        else:
            business_template_info = BusinessTemplateInfoTar(url)
        business_template_info_list.append(business_template_info)

    for business_template_info in business_template_info_list:
        for portal_type, action_information_list in business_template_info.actions.items(
        ):
            for action_information in action_information_list:
                if (action_information['category']
                        in ('object_view', 'object_list')
                        and action_information['visible'] == 1
                        and action_information['action'].startswith(
                            'string:${object_url}/')
                        and len(action_information['action'].split('/')) == 2):
                    view_name = action_information['action'].split(
                        '/')[-1].split('?')[0]
                    method = makeTestMethod(validator, portal_type, view_name,
                                            business_template_info.title)
                    method_name = (
                        'test_%s_%s_%s' % (
                            business_template_info.title,
                            str(portal_type).replace(' ',
                                                     '_'),  # can be unicode
                            view_name))
                    method.__name__ = method_name
                    if method_name in expected_failure_list:
                        method = unittest.expectedFailure(method)
                    setattr(test_class, method_name, method)