コード例 #1
0
    def testcase_prerun(self, tc_filepath, check_files_dict=None):
        """Executes prerun of a testcase file """
        print('\n')
        print_info('=' * 40)
        print_debug("Validating Test case xml")
        print_info('=' * 40)

        testcase_xsd_fullpath = self.xsd_dir + os.sep + 'warrior_testcase.xsd'
        #print_info("Test case_xsd_location: {0}".format(testcase_xsd_fullpath))

        tc_status = self.xml_to_xsd_validation(tc_filepath,
                                               testcase_xsd_fullpath)

        if tc_status:
            data_file_valid = self.check_tc_input_datafile(
                tc_filepath, check_files_dict)
            tc_status &= data_file_valid
            steps_field_valid = self.check_steps(tc_filepath)
            tc_status &= steps_field_valid
        else:
            print_error("Incorrect xml format")
        time.sleep(5)
        status = testcase_Utils.convertLogic(tc_status)
        print_info('TC STATUS: {0}ED'.format(status))

        return tc_status
コード例 #2
0
def report_testcase_result(tc_status, data_repository):
    """Report the testcase result to the result file

    :Arguments:
        1. tc_status (bool) = status of the executed testcase
        2. data_repository (dict) = data_repository of the executed  testcase
    """
    print_info("\n**** Testcase Result ***")
    print_info("TESTCASE:{0}  STATUS:{1}".format(data_repository['wt_name'],
                                                 convertLogic(tc_status)))
    print("\n")
    Utils.testcase_Utils.pTestResult(tc_status,
                                     data_repository['wt_resultfile'])
    root = Utils.xml_Utils.getRoot(data_repository['wt_resultfile'])
    fail_count = 0
    for value in root.findall('Keyword'):
        kw_status = value.find('KeywordStatus').text
        if kw_status != "PASS":
            fail_count += 1
            kw_name = value.find('Name').text
            get_step_value = value.attrib.values()
            step_num = ','.join(get_step_value)
            if fail_count == 1:
                print_info(
                    "++++++++++++++++++++++++ Summary of Failed Keywords ++++++++++++++++++++++++"
                )
                print_info("{0:15} {1:45} {2:10}".format(
                    'StepNumber', 'KeywordName', 'Status'))
                print_info("{0:15} {1:45} {2:10}".format(
                    str(step_num), str(kw_name), str(kw_status)))
            elif fail_count > 1:
                print_info("{0:15} {1:45} {2:10}".format(
                    str(step_num), str(kw_name), str(kw_status)))
    print_info(
        "=================== END OF TESTCASE ===========================")
コード例 #3
0
def main(parameter_list):
    """Check the validity of testcase/testuite/project xml files """
    valid = True
    print_info("="*10 + "PRE-RUN XML VALIDATION"+ "="*10 + "\n")
    if len(parameter_list) > 0:
        for parameter in parameter_list:
            # check if the input parameter is an xml file
            if file_Utils.get_extension_from_path(parameter) == '.xml':
                filepath = parameter
                abs_filepath = file_Utils.getAbsPath(filepath, os.curdir)
                res = iron_claw_warrior_xml_files(abs_filepath)
                result = testcase_Utils.convertLogic(res)
                valid &= res
                print_info("File '{0}' '{1}ED' Warrior prerun"\
                           "validation".format(abs_filepath, result))
            else:
                print_error("Provided file '{0}' is not an xml file".format(parameter))
    else:
        print_error("No input files provided to be validated")
        valid = False
    print '\n'
    print_info("Validation Completed:")
    if valid:
        print_info("Files are compatible with WARRIOR \n")

    else:
        print_error("Files failed Warrior Ironclaw validation\n")
    return valid


    
コード例 #4
0
    def testsuite_prerun(self,
                         testsuite_filepath,
                         root,
                         check_files_dict=None):
        """Executes prerun of a testsuite file """
        print('\n')
        print_info('*' * 40)
        print_debug("Validating Test suite xml")
        print_info('*' * 40)

        testsuite_xsd_fullpath = self.xsd_dir + os.sep + 'warrior_suite.xsd'
        testsuite_status = self.xml_to_xsd_validation(testsuite_filepath,
                                                      testsuite_xsd_fullpath)
        if testsuite_status:
            data_file_valid, check_files_dict = self.check_testsuite_input_datafile(\
                testsuite_filepath, check_files_dict)
            testsuite_status &= data_file_valid
            for testcase in root.iter('Testcase'):
                tc_path_rel = testsuite_utils.get_path_from_xmlfile(testcase)
                tc_path = file_Utils.getAbsPath(
                    tc_path_rel, os.path.dirname(testsuite_filepath))
                time.sleep(5)
                if os.path.isfile(tc_path):
                    print('\n')
                    print_info('tc_path: {0}, Testcase file exists...'.format(
                        tc_path))
                    tc_status = self.testcase_prerun(tc_path, check_files_dict)
                else:
                    print('\n')
                    tc_status = False
                    print_error(
                        'tc_path: {0}, Testcase file does not exist'.format(
                            tc_path))
                    print_info('TC STATUS: {0}'.format('FAILED'))
                testsuite_status &= tc_status

        else:
            print_error("Incorrect xml format")

        time.sleep(5)
        print('\n')
        status = testcase_Utils.convertLogic(testsuite_status)
        print_info('SUITE STATUS: {0}ED'.format(status))

        return testsuite_status
コード例 #5
0
    def project_prerun(self, project_filepath, root):
        """Executes prerun of a project file """

        print('\n')
        print_info('+' * 40)
        print_debug("Validating Project xml")
        print_info('+' * 40)
        project_xsd_fullpath = self.xsd_dir + os.sep + 'warrior_project.xsd'
        project_status = self.xml_to_xsd_validation(project_filepath,
                                                    project_xsd_fullpath)
        if project_status:
            check_files_dict = self.check_proj_results_logsdir(
                project_filepath)
            for testsuite in root.iter('Testsuite'):
                testsuite_path_rel = testsuite_utils.get_path_from_xmlfile(
                    testsuite)
                testsuite_path = file_Utils.getAbsPath(
                    testsuite_path_rel, os.path.dirname(project_filepath))

                if os.path.isfile(testsuite_path):
                    print('\n')
                    print_info("Testsuite_path: {0}, Testsuite"\
                               "file exists...".format(testsuite_path))
                    ts_root = xml_Utils.getRoot(testsuite_path)
                    tsuite_status = self.testsuite_prerun(
                        testsuite_path, ts_root, check_files_dict)
                else:
                    print('\n')
                    tsuite_status = False
                    print_error('testsuite_path: {0},\
                                Testsuite file does not exist'.format(
                        testsuite_path))
                    print_info('SUITE STATUS: {0}'.format('FAILED'))
                project_status &= tsuite_status

        else:
            print_error("Incorrect xml format")

        time.sleep(5)
        print('\n')
        status = testcase_Utils.convertLogic(project_status)
        print_info('PROJECT STATUS: {0}ED'.format(status))

        return project_status