Loading doc/statisticsDocumentationData.py +67 −27 Original line number Diff line number Diff line Loading @@ -13,10 +13,12 @@ if __name__ == "__main__": number_of_all_testcases = 0 number_of_successes = 0 ROBOT_FILE_EXTENSION = ".robot" BASE_URL_OF_FORGE = "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/blob/master/TP/NGSI-LD/" BASE_URL_OF_FORGE = ( "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/blob/master/TP/NGSI-LD/" ) fullpath = basedir + "/TP/NGSI-LD" excluded_dirs = [''] excluded_dirs = [""] for root, dirs, files in walk(fullpath): if root == fullpath: dirs[:] = [d for d in dirs if d not in excluded_dirs] Loading @@ -28,13 +30,22 @@ if __name__ == "__main__": 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"]: if ( "error_while_parsing" in json_of_test_case and json_of_test_case["error_while_parsing"] ): 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"}] 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 Loading @@ -43,14 +54,17 @@ if __name__ == "__main__": # establish the right configuration if json_of_test_case["robotpath"].startswith("ContextSource"): json_of_test_case["config_id"] = "CF_05" elif 'cf_06' in json_of_test_case["test_cases"][0]["tags"]: elif "cf_06" in json_of_test_case["test_cases"][0]["tags"]: json_of_test_case["config_id"] = "CF_06" else: json_of_test_case["config_id"] = "CF_01" # upgrade the version and add the reference in square brackets json_of_test_case["reference"] = ( re.sub(r"V1.3.1 \[\]", "version 1.5.1 [1]", json_of_test_case["reference"])) json_of_test_case["reference"] = re.sub( r"V1\.[3-6]\.1 \[\]", "V1.6.1 [1]", json_of_test_case["reference"], ) # now for each permutation inside this test case, create the permutation's correct parent_release if "test_cases" in json_of_test_case: Loading @@ -59,13 +73,18 @@ if __name__ == "__main__": # default parent release parent_release = "v1.3.1" for tag in permutation_body["tags"]: if tag.startswith('since_'): parts = tag.split('_') if tag.startswith("since_"): parts = tag.split("_") # the suffix parent_release = parts[-1] permutation_body["permutation_parent_release"] = parent_release permutation_body["permutation_parent_release"] = ( parent_release ) else: print("NO PERMUTATIONS in TESTCASE??? " + json_of_test_case["tp_id"]) print( "NO PERMUTATIONS in TESTCASE??? " + json_of_test_case["tp_id"] ) exit(1) testcases.append(json_of_test_case) print() Loading @@ -76,10 +95,12 @@ if __name__ == "__main__": if testcaseresult["failed"]: print(testcasename + " " + testcaseresult["path"]) print(f"Out of {number_of_all_testcases} testcases, {number_of_failures} of them failed to be correctly parsed.") print( f"Out of {number_of_all_testcases} testcases, {number_of_failures} of them failed to be correctly parsed." ) testcases_file = join(basedir, "doc", "results", "testcases.json") with open(testcases_file, 'w') as fp: with open(testcases_file, "w") as fp: json.dump(obj=testcases, indent=2, fp=fp) # determine the structure/schema of a successfully parsed testcase Loading Loading @@ -107,9 +128,13 @@ if __name__ == "__main__": # 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 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["stripped_permutation_tp_id"] = ( "UNKNOWN" ) permutation_body_template["robotlink"] = "UNKNOWN" for key, value in permutation_body.items(): if type(key) is str: Loading @@ -126,7 +151,10 @@ if __name__ == "__main__": 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} permutation_template = { **permutation_metadata_template, **permutation_body_template, } else: print("NO PERMUTATION TP ID") exit(1) Loading @@ -152,8 +180,13 @@ if __name__ == "__main__": permutation_metadata[key] = value # start creating HTML link to robot file in repo fullurl = (BASE_URL_OF_FORGE + permutation_metadata["robotpath"] + "/" + permutation_metadata["robotfile"] + ROBOT_FILE_EXTENSION) 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, Loading @@ -168,11 +201,18 @@ if __name__ == "__main__": # print("::: "+ptpid) # strip from beginning up to including the last "/" permutation_body["stripped_permutation_tp_id"] = ptpid[ptpid.rindex("/")+1:] permutation_body["stripped_permutation_tp_id"] = ptpid[ ptpid.rindex("/") + 1 : ] # use the stripped_permutation_tp_id as text of the link permutation_body["robotlink"] = ( "<a href=\""+fullurl+"\">" + permutation_body["stripped_permutation_tp_id"] + "</a>") '<a href="' + fullurl + '">' + permutation_body["stripped_permutation_tp_id"] + "</a>" ) # So basically we append to the permutations a new dict that is the | union merge of the # items of the template merged with the items of the concatenation of {**permutation_metadata, Loading @@ -199,5 +239,5 @@ if __name__ == "__main__": exit(1) permutations_file = join(basedir, "doc", "results", "permutations.json") with open(permutations_file, 'w') as fp: with open(permutations_file, "w") as fp: json.dump(obj=permutations, indent=2, fp=fp) Loading
doc/statisticsDocumentationData.py +67 −27 Original line number Diff line number Diff line Loading @@ -13,10 +13,12 @@ if __name__ == "__main__": number_of_all_testcases = 0 number_of_successes = 0 ROBOT_FILE_EXTENSION = ".robot" BASE_URL_OF_FORGE = "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/blob/master/TP/NGSI-LD/" BASE_URL_OF_FORGE = ( "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/blob/master/TP/NGSI-LD/" ) fullpath = basedir + "/TP/NGSI-LD" excluded_dirs = [''] excluded_dirs = [""] for root, dirs, files in walk(fullpath): if root == fullpath: dirs[:] = [d for d in dirs if d not in excluded_dirs] Loading @@ -28,13 +30,22 @@ if __name__ == "__main__": 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"]: if ( "error_while_parsing" in json_of_test_case and json_of_test_case["error_while_parsing"] ): 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"}] 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 Loading @@ -43,14 +54,17 @@ if __name__ == "__main__": # establish the right configuration if json_of_test_case["robotpath"].startswith("ContextSource"): json_of_test_case["config_id"] = "CF_05" elif 'cf_06' in json_of_test_case["test_cases"][0]["tags"]: elif "cf_06" in json_of_test_case["test_cases"][0]["tags"]: json_of_test_case["config_id"] = "CF_06" else: json_of_test_case["config_id"] = "CF_01" # upgrade the version and add the reference in square brackets json_of_test_case["reference"] = ( re.sub(r"V1.3.1 \[\]", "version 1.5.1 [1]", json_of_test_case["reference"])) json_of_test_case["reference"] = re.sub( r"V1\.[3-6]\.1 \[\]", "V1.6.1 [1]", json_of_test_case["reference"], ) # now for each permutation inside this test case, create the permutation's correct parent_release if "test_cases" in json_of_test_case: Loading @@ -59,13 +73,18 @@ if __name__ == "__main__": # default parent release parent_release = "v1.3.1" for tag in permutation_body["tags"]: if tag.startswith('since_'): parts = tag.split('_') if tag.startswith("since_"): parts = tag.split("_") # the suffix parent_release = parts[-1] permutation_body["permutation_parent_release"] = parent_release permutation_body["permutation_parent_release"] = ( parent_release ) else: print("NO PERMUTATIONS in TESTCASE??? " + json_of_test_case["tp_id"]) print( "NO PERMUTATIONS in TESTCASE??? " + json_of_test_case["tp_id"] ) exit(1) testcases.append(json_of_test_case) print() Loading @@ -76,10 +95,12 @@ if __name__ == "__main__": if testcaseresult["failed"]: print(testcasename + " " + testcaseresult["path"]) print(f"Out of {number_of_all_testcases} testcases, {number_of_failures} of them failed to be correctly parsed.") print( f"Out of {number_of_all_testcases} testcases, {number_of_failures} of them failed to be correctly parsed." ) testcases_file = join(basedir, "doc", "results", "testcases.json") with open(testcases_file, 'w') as fp: with open(testcases_file, "w") as fp: json.dump(obj=testcases, indent=2, fp=fp) # determine the structure/schema of a successfully parsed testcase Loading Loading @@ -107,9 +128,13 @@ if __name__ == "__main__": # 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 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["stripped_permutation_tp_id"] = ( "UNKNOWN" ) permutation_body_template["robotlink"] = "UNKNOWN" for key, value in permutation_body.items(): if type(key) is str: Loading @@ -126,7 +151,10 @@ if __name__ == "__main__": 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} permutation_template = { **permutation_metadata_template, **permutation_body_template, } else: print("NO PERMUTATION TP ID") exit(1) Loading @@ -152,8 +180,13 @@ if __name__ == "__main__": permutation_metadata[key] = value # start creating HTML link to robot file in repo fullurl = (BASE_URL_OF_FORGE + permutation_metadata["robotpath"] + "/" + permutation_metadata["robotfile"] + ROBOT_FILE_EXTENSION) 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, Loading @@ -168,11 +201,18 @@ if __name__ == "__main__": # print("::: "+ptpid) # strip from beginning up to including the last "/" permutation_body["stripped_permutation_tp_id"] = ptpid[ptpid.rindex("/")+1:] permutation_body["stripped_permutation_tp_id"] = ptpid[ ptpid.rindex("/") + 1 : ] # use the stripped_permutation_tp_id as text of the link permutation_body["robotlink"] = ( "<a href=\""+fullurl+"\">" + permutation_body["stripped_permutation_tp_id"] + "</a>") '<a href="' + fullurl + '">' + permutation_body["stripped_permutation_tp_id"] + "</a>" ) # So basically we append to the permutations a new dict that is the | union merge of the # items of the template merged with the items of the concatenation of {**permutation_metadata, Loading @@ -199,5 +239,5 @@ if __name__ == "__main__": exit(1) permutations_file = join(basedir, "doc", "results", "permutations.json") with open(permutations_file, 'w') as fp: with open(permutations_file, "w") as fp: json.dump(obj=permutations, indent=2, fp=fp)