Skip to content
Commits on Source (2)
......@@ -37,10 +37,10 @@ ${subscription_payload_file_path}= csourceSubscriptions/subscription-sample
Check Created Resource Set To ${subscription_payload} ${response1.json()} ${ignored_attributes}
Check Dictionary Might Contain Additional Members ${response1.json()} lastNotification
Check Dictionary Might Contain Additional Members ${response1.json()} lastFailure
Check Dictionary Might Contain Additional Members ${response1.json()} lastSuccess
Check Dictionary Might Contain Additional Members ${response1.json()} timesSent
Check Dictionary Might Contain Additional Members of the NotificationParams ${response1.json()} lastNotification
Check Dictionary Might Contain Additional Members of the NotificationParams ${response1.json()} lastFailure
Check Dictionary Might Contain Additional Members of the NotificationParams ${response1.json()} lastSuccess
Check Dictionary Might Contain Additional Members of the NotificationParams ${response1.json()} timesSent
*** Keywords ***
......
......@@ -51,10 +51,10 @@ ${expectation_file_path}= csourceSubscriptions/expectations/subscr
... response_body=${response.json()}
... ignored_keys=${ignored_attributes}
Check Dictionary Might Contain Additional Members ${response.json()} lastNotification
Check Dictionary Might Contain Additional Members ${response.json()} lastFailure
Check Dictionary Might Contain Additional Members ${response.json()} lastSuccess
Check Dictionary Might Contain Additional Members ${response.json()} timesSent
Check Dictionary Might Contain Additional Members of the NotificationParams ${response.json()} lastNotification
Check Dictionary Might Contain Additional Members of the NotificationParams ${response.json()} lastFailure
Check Dictionary Might Contain Additional Members of the NotificationParams ${response.json()} lastSuccess
Check Dictionary Might Contain Additional Members of the NotificationParams ${response.json()} timesSent
*** Keywords ***
......
......@@ -62,7 +62,7 @@ class Checks:
Checks.check_response_body_contains_datetime_value,
'Check Response Body Containing ProblemDetails Element Containing Title Element':
Checks.check_response_body_containing_problemdetails_element_containing_title_element,
'Check Dictionary Might Contain Additional Members':
'Check Dictionary Might Contain Additional Members of the NotificationParams':
Checks.check_dictionary_might_contain_additional_members,
'Check Response Body Containing ProblemDetails Element':
Checks.check_response_body_containing_problemdetails_element,
......@@ -149,7 +149,7 @@ class Checks:
'params': ['response_body'],
'position': [0]
},
'Check Dictionary Might Contain Additional Members': {
'Check Dictionary Might Contain Additional Members of the NotificationParams': {
'params': ['dictionary', 'key'],
'position': [0, 1]
},
......
......@@ -23,10 +23,12 @@ def create_json_of_robotfile(robot_file_to_be_processed: str, computestatistics:
data = GenerateRobotData(robot_file=robot_file, execdir=folder_test_suites)
data.parse_robot()
info = data.get_info()
info["error_while_autogenerating"] = "no error"
except Exception as e:
print("WHILE GENERATING ROBOT DATA:", e)
info = dict()
info["error_while_parsing"] = True
info["error_while_autogenerating"] = str(e)
info["robotfile"] = robot_file_to_be_processed
if(robot_path_to_be_processed.startswith("/")):
robot_path_to_be_processed = robot_path_to_be_processed[1:]
......
from generateDocumentationData import create_json_of_robotfile
from os.path import dirname
from os import walk
from json import dump
import requests
import json
import re
if __name__ == "__main__":
basedir = dirname(dirname(__file__))
......@@ -11,6 +13,7 @@ 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/tests-up-to-1_5/TP/NGSI-LD/"
fullpath = basedir+"/TP/NGSI-LD"
for root, dirs, files in walk(fullpath):
......@@ -25,10 +28,38 @@ if __name__ == "__main__":
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"}]
else:
statistics[name_of_test_case]["failed"] = False
number_of_successes += 1
testcases.append(json_of_test_case)
# we add it here because Fernando's code does not, in case of successfull parsing
json_of_test_case["error_while_parsing"] = False
# establish the right configuration
if json_of_test_case["robotpath"].startswith("ContextSource"):
json_of_test_case["config_id"] = "CF_05"
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"])
# now for each permutation inside this test case, create the permutation's correct parent_release
if "test_cases" in json_of_test_case:
# grab everything that is a permutation_body inside the "sub" test_cases,
for permutation_body in json_of_test_case["test_cases"]:
# default parent release
parent_release = "v1.3.1"
for tag in permutation_body["tags"]:
if tag.startswith('since_'):
parts = tag.split('_')
# the suffix
parent_release = parts[-1]
permutation_body["permutation_parent_release"] = parent_release
else:
print("NO PERMUTATIONS in TESTCASE??? " + json_of_test_case["tp_id"])
exit(1)
testcases.append(json_of_test_case)
print()
print()
......@@ -40,5 +71,131 @@ if __name__ == "__main__":
print(f"Out of {number_of_all_testcases} testcases, {number_of_failures} of them failed to be correctly parsed.")
with open("./results/testcases.json", 'w') as fp:
dump(obj=testcases, indent=2, fp=fp)
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
# 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"]
if "then" not in permutation_body:
print(" no then in " + ptpid)
if "when" not in permutation_body:
print(" no when in " + ptpid)
#print("::: "+ptpid)
# strip from beginning up to including the last "/"
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>"
# 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, **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}
unpacked_testcase = {**permutation_template, **a}
# Perform a check on the clauses that must be equal to the
# clauses extracted from tags
if "clauses" not in unpacked_testcase:
print("NO EXTRACTED CLAUSES in " + ptpid)
exit(1)
if len(unpacked_testcase["clauses"]) > 1:
print("MULTIPLE CLAUSES in " + ptpid)
permutations.append(unpacked_testcase)
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)
# The URL of the REST endpoint of the NoSQL database
dburl = 'http://ec2-18-153-159-20.eu-central-1.compute.amazonaws.com:5555/fromrobot'
requests.delete(dburl)
# Set the appropriate headers for JSON, if required by the endpoint
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
# Include any other headers the API requires
}
# Make the POST request
response = requests.post(dburl, data=json.dumps(permutations), headers=headers)
......@@ -475,7 +475,7 @@ Check Retrieving Context Source Registration
${ignored_attributes}= Create List ${status_regex_expr} @context
Check Updated Resource Set To ${registration_payload} ${response.json()} ${ignored_attributes}
Check Dictionary Might Contain Additional Members
Check Dictionary Might Contain Additional Members of the NotificationParams
# Check the Additional Members 5.2.14.2 in the NotificationParams data structure
[Arguments] ${dictionary} ${key}
Log Dictionary Might Contain Key with a specific type
......