コード例 #1
0
 def get_jira_system_creds(datafile, system_name, list_my_info):
     """Returns a python dictionary containing key value pairs of
     requested info and their values for the provided system name from the datafile """
     if system_name is not None:
         element = xml_Utils.getElementWithTagAttribValueMatch(datafile,
                                                               'system',
                                                               'name',
                                                               system_name)
     else:
         element = xml_Utils.getElementWithTagAttribValueMatch(datafile, 'system',
                                                               'default', "true")
         if element is None:
             node_value = xml_Utils.getNodeValuebyAttribute(datafile, 'system', 'name')
             element = xml_Utils.getElementWithTagAttribValueMatch(datafile, 'system',
                                                                   'name',
                                                                   node_value)
     if element is not None and element is not False:
         output_dict = {}
         for item in list_my_info:
             output_dict[item] = xml_Utils.get_text_from_direct_child(element, item)
         return output_dict
     else:
         msg = ("There is no project with name: '{0}' in the jira config "
                "file: '{1}'".format(system_name, "Tools/jira/jira_config.xml"))
         print_warning(msg)
         return False
コード例 #2
0
    def _get_iteration_syslist(self, system_node_list, system_name_list):
        """
        Process the initial system_list and remove the systems
        that do not have iter=yes.
        """
        iteration_syslist = []
        for i in range(0, len(system_node_list)):
            system = system_node_list[i]
            iter_flag = system.get("iter", None)
            if iter_flag is None:
                iter_flag = xml_Utils.get_text_from_direct_child(
                    system, "iter")
            iter_flag = data_Utils.sub_from_env_var(iter_flag)

            if str(iter_flag).lower() == "no":
                pass
            else:
                system_name = system_name_list[i]
                if not system_name:
                    pNote("No name provided for system/susbsystem in datafile",
                          "error")
                else:
                    iteration_syslist.append(system_name)

        return iteration_syslist
コード例 #3
0
def get_jiraids_from_xmlfile(element):
    """Gets the jiraid value of a testcase from the testsuite.xml file """

    jiraids = xml_Utils.get_text_from_direct_child(element, 'jiraid')
    if jiraids is not None and jiraids is not False:
        jiraids = [jiraid.strip() for jiraid in jiraids.split(",")]
    return jiraids
コード例 #4
0
def get_path_from_xmlfile(element):
    """Gets the testcase/testsuite path  from the testsuite.xml/project.xml file """

    path = xml_Utils.get_text_from_direct_child(element, 'path')
    if path is None or path is False:
        print_error("path cannot be empty check input xml file")
        path = None
    elif path is not None and path is not False:
        path = path.strip()
    return path
コード例 #5
0
def get_data_file_at_suite_step(element, suite_repository):
    """Gets the testcase/testsuite path  from the testsuite.xml/project.xml file """

    if suite_repository["suite_exectype"].upper() == "ITERATIVE_SEQUENTIAL" \
       or suite_repository["suite_exectype"].upper() == "ITERATIVE_PARALLEL":
        print_info("Suite exectype=iterative, so all testcases in the suite will use the suite datafile as their input datafile")
        data_file = suite_repository["data_file"]
    else:
        data_file = xml_Utils.get_text_from_direct_child(element, 'InputDataFile')
    if data_file is None or data_file is False:
        data_file = None
    elif data_file is not None and data_file is not False:
        data_file = str(data_file).strip()
    return data_file
コード例 #6
0
def get_runtype_from_xmlfile(element):
    """Gets the runtype value of a testcase from the testsuite.xml file """
    
    runtype = xml_Utils.get_text_from_direct_child(element, 'runtype')
    if runtype is None or runtype is False:
        runtype='sequential_keywords'
    elif runtype is not None and runtype is not False:
        runtype = runtype.strip()
        supported_values = ['sequential_keywords', 'parallel_keywords']
        if runtype.lower() not in supported_values:
            print_warning("unsupported value '{0}' provided for runtype, supported values are '{1}', case-insensitive".format(runtype, supported_values))
            print_info("Hence using default value for runtype which is 'sequential_keywords'")
            runtype = 'sequential_keywords'
    return runtype
コード例 #7
0
def get_database_details(config_file, server_type, system_name, info_list):
    """ To get the database system details from database config file """

    system = server_type + "/system"
    if system_name is not None:
        element = xml_Utils.getElementWithTagAttribValueMatch(
            config_file, system, 'name', system_name)
    else:
        element = xml_Utils.getElementWithTagAttribValueMatch(
            config_file, system, 'default', "true")
        if element is None:
            node_value = xml_Utils.getNodeValuebyAttribute(
                config_file, system, 'name')
            element = xml_Utils.getElementWithTagAttribValueMatch(
                config_file, system, 'name', node_value)

    if element is not None and element is not False:
        output_dict = {}
        for item in info_list:
            output_dict[item] = xml_Utils.get_text_from_direct_child(
                element, item)
        return output_dict
    else:
        if system_name is not None:
            msg = "There is no system with name: '{0}' under '{1}' in " \
                  "the database config file: '{2}'".format(system_name,
                                                           server_type,
                                                           config_file)
            print_warning(msg)
        elif server_type == "dataservers":
            msg = "Value for td_system/var_system tag is not provided in " \
                  "the datafile and there is no system listed in database " \
                  "config file under dataservers block to be used as default"
            print_warning(msg)

        return False
コード例 #8
0
def create_case_junit(robot_tests):
    """ Add robot test results into Warrior Junit XML object
    :Argument:
        1. robot_tests(list) - Robot test xml elements
    """

    data_repository = config_Utils.data_repository
    tc_junit_object = data_repository['wt_junit_object']
    for test_elem in robot_tests:
        test_name = test_elem.get('name')

        tc_start_time = xml_Utils.get_attributevalue_from_directchildnode(
         test_elem, 'status', 'starttime')
        tc_start_time = datetime.datetime.strptime(
         tc_start_time, "%Y%m%d %H:%M:%S.%f").replace(microsecond=0)
        tc_timestamp = str(tc_start_time)
        tc_end_time = xml_Utils.get_attributevalue_from_directchildnode(
         test_elem, 'status', 'endtime')
        tc_end_time = datetime.datetime.strptime(
         tc_end_time, "%Y%m%d %H:%M:%S.%f").replace(microsecond=0)
        tc_duration = datetime_utils.get_time_delta(tc_start_time, tc_end_time)
        tc_status = xml_Utils.get_attributevalue_from_directchildnode(test_elem, 'status','status')

        tc_junit_object.create_testcase(location="from testsuite", timestamp=tc_timestamp,
                                        ts_timestamp=data_repository['wt_ts_timestamp'],
                                        classname=data_repository['wt_suite_name'],
                                        name=test_name,
                                        testcasefile_path=data_repository['wt_testcase_filepath'])
        tc_junit_object.add_property("resultsdir",
                                     os.path.dirname(data_repository['wt_resultsdir']),
                                    "tc", tc_timestamp)
        tc_junit_object.add_property("logsdir", os.path.dirname(data_repository['wt_logsdir']),
                                    "tc", tc_timestamp)
        tc_junit_object.update_attr("title", test_name, "tc", tc_timestamp)

        string_status = {"PASS": "******", "FAIL": "FALSE"}
        # Convert robot test results
        if str(tc_status).upper() in list(string_status.keys()):
            tc_status = string_status[str(tc_status).upper()]
        tc_junit_object.update_count(tc_status, "1", "ts", data_repository['wt_ts_timestamp'])
        tc_junit_object.update_count("tests", "1", "ts", data_repository['wt_ts_timestamp'])
        tc_junit_object.update_count("tests", "1", "pj", "not appicable")
        tc_junit_object.update_attr("status", str(tc_status), "tc", tc_timestamp)
        tc_junit_object.update_attr("time", str(tc_duration), "tc", tc_timestamp)
        tc_junit_object.add_testcase_message(tc_timestamp, tc_status)

        keywords = test_elem.getchildren()
        step_num = 1
        for kw_elem in keywords:
            if kw_elem.tag == "kw":
                kw_name = kw_elem.get('name')
                kw_start_time = xml_Utils.get_attributevalue_from_directchildnode(
                 kw_elem, 'status', 'starttime')
                kw_start_time = datetime.datetime.strptime(
                 kw_start_time, "%Y%m%d %H:%M:%S.%f").replace(microsecond=0)
                kw_end_time = xml_Utils.get_attributevalue_from_directchildnode(
                 kw_elem, 'status', 'endtime')
                kw_end_time = datetime.datetime.strptime(
                 kw_end_time, "%Y%m%d %H:%M:%S.%f").replace(microsecond=0)
                kw_duration = datetime_utils.get_time_delta(kw_start_time, kw_end_time)

                kw_status = xml_Utils.get_attributevalue_from_directchildnode(
                 kw_elem, 'status', 'status')

                kw_desc = xml_Utils.get_text_from_direct_child(kw_elem, 'doc')
                if kw_desc is False:
                    kw_desc = "No doc/desc provided"

                # Convert robot keyword results
                if str(kw_status).upper() in list(string_status.keys()):
                    kw_status = string_status[str(kw_status).upper()]

                add_keyword_result(tc_junit_object, tc_timestamp, step_num,
                                   kw_name, kw_status, kw_start_time,
                                   kw_duration, "skipped", "Impact", "Next", kw_desc)
                step_num += 1