Loading doc/statisticsDocumentationData.py +97 −15 Original line number Diff line number Diff line Loading @@ -21,19 +21,21 @@ if __name__ == "__main__": number_of_all_testcases += 1 name_of_test_case = filename[:-len(ROBOT_FILE_EXTENSION)] json_of_test_case = create_json_of_robotfile(name_of_test_case, True) # add HTML link to robot file in repo fullurl = BASE_URL_OF_FORGE + json_of_test_case["robotpath"] + "/" + json_of_test_case["robotfile"] + ROBOT_FILE_EXTENSION # use the file name as text of the link json_of_test_case["robotlink"] = "<a href=\""+fullurl+"\">" + json_of_test_case["robotfile"] + "</a>" statistics[name_of_test_case] = dict() strippedpath = root[len(fullpath)+1:] statistics[name_of_test_case]["path"] = strippedpath if "error_while_parsing" in json_of_test_case and json_of_test_case["error_while_parsing"] == True: statistics[name_of_test_case]["failed"] = True number_of_failures += 1 # we create a dummy entry in the "sub" test_cases, which has a "permutation_tp_id" equal to the robotfile # We do not forget to add a trailing slash that will be removed later, and a tail _XX which will # allow matching from the googlesheet? json_of_test_case["test_cases"] = [{"permutation_tp_id":"/"+json_of_test_case["robotfile"]+"_XX"}] else: statistics[name_of_test_case]["failed"] = False number_of_successes += 1 # we add it here because Fernando's code does not, in case of successfull parsing json_of_test_case["error_while_parsing"] = False testcases.append(json_of_test_case) print() Loading @@ -49,25 +51,105 @@ if __name__ == "__main__": with open("testcases.json", 'w') as fp: json.dump(obj=testcases, indent=2, fp=fp) # determine the structure/schema of a successfully parsed testcase permutation_template = {} for testcase in testcases: if testcase["error_while_parsing"] == False: permutation_metadata_template = {} # everything that is at the top level shall be extracted for key, value in testcase.items(): if key != "test_cases": if type(key) is str: permutation_metadata_template[key] = "UNKNOWN" elif type(key) is list: permutation_metadata_template[key] = [] elif type(key) is int: permutation_metadata_template[key] = 0 elif type(key) is float: permutation_metadata_template[key] = 0.0 elif type(key) is dict: permutation_metadata_template[key] = {} else: print("UNKNOWN type") exit(1) if "test_cases" in testcase: # everything that is a permutation_body inside the "sub" test_cases, # shall rise on its own existenz and be joined with its permutation_metadata for permutation_body in testcase["test_cases"]: permutation_body_template = {} # new object, not changing permutation_body if "permutation_tp_id" in permutation_body: permutation_body_template["stripped_permutation_tp_id"] = "UNKNOWN" permutation_body_template["robotlink"] = "UNKNOWN" for key, value in permutation_body.items(): if type(key) is str: permutation_body_template[key] = "UNKNOWN" elif type(key) is list: permutation_body_template[key] = [] elif type(key) is int: permutation_body_template[key] = 0 elif type(key) is float: permutation_body_template[key] = 0.0 elif type(key) is dict: permutation_body_template[key] = {} else: print("UNKNOWN BODY type") exit(1) # we use the unpacking python operator ** that strips the container dict from both permutation_template = {**permutation_metadata_template, **permutation_body_template} else: print("NO PERMUTATION TP ID") exit(1) else: print("TEMPLATE PARSING NOT FAILED, BUT no permutations??") exit(1) if permutation_template != {}: break print() print("Typical template:") print(permutation_template) # unpack all permutations of testcases that are under the same .robot file permutations = [] for testcase in testcases: print("--parsing "+testcase["robotfile"]) permutation_metadata = {} # everything that is at the top level shall be extracted for key, value in testcase.items(): if key != "test_cases": permutation_metadata[key] = value # everything that is a permutation_body inside, shall rise on its own existenz and be joined with its eprmutation_metadata # start creating HTML link to robot file in repo fullurl = BASE_URL_OF_FORGE + permutation_metadata["robotpath"] + "/" + permutation_metadata["robotfile"] + ROBOT_FILE_EXTENSION if "test_cases" in testcase: # everything that is a permutation_body inside the "sub" test_cases, # shall rise on its own existenz and be joined with its permutation_metadata for permutation_body in testcase["test_cases"]: if "permutation_tp_id" in permutation_body: ptpid = permutation_body["permutation_tp_id"] print("::: "+ptpid) # strip from beginning up to including the last "/" permutation_body["stripped_permutation_tp_id"] = ptpid[ptpid.rindex("/")+1:] # we use the unpacking python operator ** that strips the container dict from both permutations.append({**permutation_metadata, **permutation_body}) # use the stripped_permutation_tp_id as text of the link permutation_body["robotlink"] = "<a href=\""+fullurl+"\">" + permutation_body["stripped_permutation_tp_id"] + "</a>" # So basically we append to the permutations a new dict that is the | unione merge of the # items of the template merged with the items of the concatenation of {**permutation_metadata, **permutation_body} # For this last concatenation we use the unpacking python operator ** that strips the container dict from both #permutations.append(dict(permutation_template.items() | {**permutation_metadata, **permutation_body}.items())) a = {**permutation_metadata, **permutation_body} b = {**permutation_template, **a} permutations.append(b) else: print("NO PERMUTATION TP ID") exit(1) else: # there is no "sub" test_cases, it likely is a failed parsing if testcase["error_while_parsing"] == False: print("PARSING NOT FAILED, BUT no permutations??") exit(1) with open("permutations.json", 'w') as fp: json.dump(obj=permutations, indent=2, fp=fp) Loading Loading
doc/statisticsDocumentationData.py +97 −15 Original line number Diff line number Diff line Loading @@ -21,19 +21,21 @@ if __name__ == "__main__": number_of_all_testcases += 1 name_of_test_case = filename[:-len(ROBOT_FILE_EXTENSION)] json_of_test_case = create_json_of_robotfile(name_of_test_case, True) # add HTML link to robot file in repo fullurl = BASE_URL_OF_FORGE + json_of_test_case["robotpath"] + "/" + json_of_test_case["robotfile"] + ROBOT_FILE_EXTENSION # use the file name as text of the link json_of_test_case["robotlink"] = "<a href=\""+fullurl+"\">" + json_of_test_case["robotfile"] + "</a>" statistics[name_of_test_case] = dict() strippedpath = root[len(fullpath)+1:] statistics[name_of_test_case]["path"] = strippedpath if "error_while_parsing" in json_of_test_case and json_of_test_case["error_while_parsing"] == True: statistics[name_of_test_case]["failed"] = True number_of_failures += 1 # we create a dummy entry in the "sub" test_cases, which has a "permutation_tp_id" equal to the robotfile # We do not forget to add a trailing slash that will be removed later, and a tail _XX which will # allow matching from the googlesheet? json_of_test_case["test_cases"] = [{"permutation_tp_id":"/"+json_of_test_case["robotfile"]+"_XX"}] else: statistics[name_of_test_case]["failed"] = False number_of_successes += 1 # we add it here because Fernando's code does not, in case of successfull parsing json_of_test_case["error_while_parsing"] = False testcases.append(json_of_test_case) print() Loading @@ -49,25 +51,105 @@ if __name__ == "__main__": with open("testcases.json", 'w') as fp: json.dump(obj=testcases, indent=2, fp=fp) # determine the structure/schema of a successfully parsed testcase permutation_template = {} for testcase in testcases: if testcase["error_while_parsing"] == False: permutation_metadata_template = {} # everything that is at the top level shall be extracted for key, value in testcase.items(): if key != "test_cases": if type(key) is str: permutation_metadata_template[key] = "UNKNOWN" elif type(key) is list: permutation_metadata_template[key] = [] elif type(key) is int: permutation_metadata_template[key] = 0 elif type(key) is float: permutation_metadata_template[key] = 0.0 elif type(key) is dict: permutation_metadata_template[key] = {} else: print("UNKNOWN type") exit(1) if "test_cases" in testcase: # everything that is a permutation_body inside the "sub" test_cases, # shall rise on its own existenz and be joined with its permutation_metadata for permutation_body in testcase["test_cases"]: permutation_body_template = {} # new object, not changing permutation_body if "permutation_tp_id" in permutation_body: permutation_body_template["stripped_permutation_tp_id"] = "UNKNOWN" permutation_body_template["robotlink"] = "UNKNOWN" for key, value in permutation_body.items(): if type(key) is str: permutation_body_template[key] = "UNKNOWN" elif type(key) is list: permutation_body_template[key] = [] elif type(key) is int: permutation_body_template[key] = 0 elif type(key) is float: permutation_body_template[key] = 0.0 elif type(key) is dict: permutation_body_template[key] = {} else: print("UNKNOWN BODY type") exit(1) # we use the unpacking python operator ** that strips the container dict from both permutation_template = {**permutation_metadata_template, **permutation_body_template} else: print("NO PERMUTATION TP ID") exit(1) else: print("TEMPLATE PARSING NOT FAILED, BUT no permutations??") exit(1) if permutation_template != {}: break print() print("Typical template:") print(permutation_template) # unpack all permutations of testcases that are under the same .robot file permutations = [] for testcase in testcases: print("--parsing "+testcase["robotfile"]) permutation_metadata = {} # everything that is at the top level shall be extracted for key, value in testcase.items(): if key != "test_cases": permutation_metadata[key] = value # everything that is a permutation_body inside, shall rise on its own existenz and be joined with its eprmutation_metadata # start creating HTML link to robot file in repo fullurl = BASE_URL_OF_FORGE + permutation_metadata["robotpath"] + "/" + permutation_metadata["robotfile"] + ROBOT_FILE_EXTENSION if "test_cases" in testcase: # everything that is a permutation_body inside the "sub" test_cases, # shall rise on its own existenz and be joined with its permutation_metadata for permutation_body in testcase["test_cases"]: if "permutation_tp_id" in permutation_body: ptpid = permutation_body["permutation_tp_id"] print("::: "+ptpid) # strip from beginning up to including the last "/" permutation_body["stripped_permutation_tp_id"] = ptpid[ptpid.rindex("/")+1:] # we use the unpacking python operator ** that strips the container dict from both permutations.append({**permutation_metadata, **permutation_body}) # use the stripped_permutation_tp_id as text of the link permutation_body["robotlink"] = "<a href=\""+fullurl+"\">" + permutation_body["stripped_permutation_tp_id"] + "</a>" # So basically we append to the permutations a new dict that is the | unione merge of the # items of the template merged with the items of the concatenation of {**permutation_metadata, **permutation_body} # For this last concatenation we use the unpacking python operator ** that strips the container dict from both #permutations.append(dict(permutation_template.items() | {**permutation_metadata, **permutation_body}.items())) a = {**permutation_metadata, **permutation_body} b = {**permutation_template, **a} permutations.append(b) else: print("NO PERMUTATION TP ID") exit(1) else: # there is no "sub" test_cases, it likely is a failed parsing if testcase["error_while_parsing"] == False: print("PARSING NOT FAILED, BUT no permutations??") exit(1) with open("permutations.json", 'w') as fp: json.dump(obj=permutations, indent=2, fp=fp) Loading