From 7ec25ae340bebece479b24e8df7da3eef13afaf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Thu, 28 Sep 2023 15:16:39 +0200 Subject: [PATCH 1/9] Resolved issues for 044_02 and 044_03 --- TP/NGSI-LD/CommonBehaviours/044_01.robot | 4 +- TP/NGSI-LD/CommonBehaviours/044_02.robot | 8 +- TP/NGSI-LD/CommonBehaviours/044_03.robot | 12 +- doc/analysis/checks.py | 2 +- doc/analysis/generaterobotdata.py | 22 ++- doc/analysis/parseapiutilsfile.py | 14 +- doc/analysis/parserobotfile.py | 9 +- doc/analysis/parsevariablesfile.py | 24 +++ doc/analysis/requests.py | 219 +++++++++++++++++++---- doc/files/043_01.json | 4 +- doc/files/044_01.json | 94 +++++----- doc/files/044_02.json | 81 +++++++++ doc/generateDocumentationData.py | 13 +- doc/tests/test_CommonBehaviours.py | 16 +- 14 files changed, 403 insertions(+), 119 deletions(-) create mode 100644 doc/analysis/parsevariablesfile.py create mode 100644 doc/files/044_02.json diff --git a/TP/NGSI-LD/CommonBehaviours/044_01.robot b/TP/NGSI-LD/CommonBehaviours/044_01.robot index 279678cd..bda9e724 100644 --- a/TP/NGSI-LD/CommonBehaviours/044_01.robot +++ b/TP/NGSI-LD/CommonBehaviours/044_01.robot @@ -17,7 +17,7 @@ ${subscription_fragment}= subscriptions/fragments/subscription-update-samp *** Test Cases *** -044_01_01_endpoint /entities/{entityId}/attrs/{attrId} +044_01_01 endpoint /entities/{entityId}/attrs/{attrId} [Documentation] Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type [Tags] ea-partial-update 6_3_4 ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} @@ -35,7 +35,7 @@ ${subscription_fragment}= subscriptions/fragments/subscription-update-samp Check Response Status Code 204 ${response.status_code} [Teardown] Delete Entity by Id ${entity_id} -044_01_02_endpoint /subscriptions/{subscriptionId} +044_01_02 endpoint /subscriptions/{subscriptionId} [Documentation] Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type [Tags] sub-update 6_3_4 ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} diff --git a/TP/NGSI-LD/CommonBehaviours/044_02.robot b/TP/NGSI-LD/CommonBehaviours/044_02.robot index 8f634d61..08f3134c 100644 --- a/TP/NGSI-LD/CommonBehaviours/044_02.robot +++ b/TP/NGSI-LD/CommonBehaviours/044_02.robot @@ -21,7 +21,7 @@ ${content_type}= application/json *** Test Cases *** -044_02_01_endpoint /entities/{entityId} +044_02_01 endpoint /entities/{entityId} [Documentation] Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/entities/{entityId}) [Tags] e-query 6_3_4 ${id}= Generate Random Entity Id ${building_id_prefix} @@ -36,7 +36,7 @@ ${content_type}= application/json Check Response Headers Link Not Empty ${response.headers} [Teardown] Delete Entity by Id Returning Response ${id} -044_02_02_endpoint /subscriptions/{subscriptionId} +044_02_02 endpoint /subscriptions/{subscriptionId} [Documentation] Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/subscriptions/{subscriptionId}) [Tags] sub-retrieve 6_3_4 ${id}= Generate Random Entity Id ${subscription_id_prefix} @@ -48,7 +48,7 @@ ${content_type}= application/json Check Response Headers Link Not Empty ${response.headers} [Teardown] Delete Subscription ${id} -044_02_03_endpoint /csourceRegistrations/ +044_02_03 endpoint /csourceRegistrations/ [Documentation] Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/csourceRegistrations/) [Tags] csr-query 6_3_4 ${registration_id}= Generate Random Entity Id ${registration_id_prefix} @@ -66,7 +66,7 @@ ${content_type}= application/json Check Response Headers Link Not Empty ${response.headers} [Teardown] Delete Context Source Registration ${registration_id} -044_02_04_endpoint /temporal/entities +044_02_04 endpoint /temporal/entities [Documentation] Verify that on a GET HTTP request if nothing is specified on the Accept header, "application/json" is assumed (/temporal/entities) [Tags] te-query 6_3_4 ${temporal_entity_representation_id}= Generate Random Entity Id ${tea_id_prefix} diff --git a/TP/NGSI-LD/CommonBehaviours/044_03.robot b/TP/NGSI-LD/CommonBehaviours/044_03.robot index 306335d6..c819f18e 100644 --- a/TP/NGSI-LD/CommonBehaviours/044_03.robot +++ b/TP/NGSI-LD/CommonBehaviours/044_03.robot @@ -22,7 +22,7 @@ ${content_type}= application/xml *** Test Cases *** -044_03_01_endpoint patch /entities/{entityId}/attrs/{attrId} +044_03_01 endpoint patch /entities/{entityId}/attrs/{attrId} [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (patch /entities/{entityId}/attrs/{attrId}) [Tags] ea-partial-update 6_3_4 ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} @@ -39,7 +39,7 @@ ${content_type}= application/xml Check Response Status Code 415 ${response.status_code} [Teardown] Delete Entity by Id Returning Response ${entity_id} -044_03_02_endpoint patch /subscriptions/{subscriptionId} +044_03_02 endpoint patch /subscriptions/{subscriptionId} [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (patch /subscriptions/{subscriptionId}) [Tags] sub-update 6_3_4 ${id}= Generate Random Entity Id ${subscription_id_prefix} @@ -49,7 +49,7 @@ ${content_type}= application/xml Check Response Status Code 415 ${response.status_code} [Teardown] Delete Subscription ${id} -044_03_03_endpoint post /entities/ +044_03_03 endpoint post /entities/ [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /entities/) [Tags] e-create 6_3_4 ${entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -60,7 +60,7 @@ ${content_type}= application/xml Check Response Status Code 415 ${response.status_code} [Teardown] Delete Entity by Id ${entity_id} -044_03_04_endpoint post /subscriptions/ +044_03_04 endpoint post /subscriptions/ [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /subscriptions/) [Tags] sub-create 6_3_4 ${subscriptions_id}= Generate Random Entity Id ${subscription_id_prefix} @@ -68,7 +68,7 @@ ${content_type}= application/xml Check Response Status Code 415 ${response.status_code} [Teardown] Delete Subscription ${subscriptions_id} -044_03_05_endpoint post /entityOperations/create +044_03_05 endpoint post /entityOperations/create [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /entityOperations/create) [Tags] be-create 6_3_4 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -81,7 +81,7 @@ ${content_type}= application/xml Check Response Status Code 415 ${response.status_code} [Teardown] Batch Delete Entities @{expected_entities_ids} -044_03_06_endpoint post /temporal/entities/ +044_03_06 endpoint post /temporal/entities/ [Documentation] Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (post /temporal/entities/) [Tags] te-create 6_3_4 ${temporal_entity_representation_id}= Generate Random Entity Id ${tea_id_prefix} diff --git a/doc/analysis/checks.py b/doc/analysis/checks.py index f0518e7b..987f0202 100644 --- a/doc/analysis/checks.py +++ b/doc/analysis/checks.py @@ -91,7 +91,7 @@ class Checks: }, 'Check Response Headers Containing Content-Type set to': { 'params': ['content_type'], - 'position': [] + 'position': [1] }, 'Check Response Body Containing an Attribute set to': { 'params': ['attribute_name'], diff --git a/doc/analysis/generaterobotdata.py b/doc/analysis/generaterobotdata.py index 98fe9bba..06b9bc51 100644 --- a/doc/analysis/generaterobotdata.py +++ b/doc/analysis/generaterobotdata.py @@ -2,12 +2,14 @@ from os.path import dirname from robot.api import TestSuiteBuilder from doc.analysis.parserobotfile import ParseRobotFile from doc.analysis.parseapiutilsfile import ParseApiUtilsFile +from doc.analysis.parsevariablesfile import ParseVariablesFile import re class GenerateRobotData: def __init__(self, robot_file: str, execdir: str): - self.robot = ParseRobotFile(filename=robot_file, execdir=execdir) + self.config_variables = ParseVariablesFile() + self.robot = ParseRobotFile(filename=robot_file, execdir=execdir, config_file=self.config_variables) self.apiutil = ParseApiUtilsFile(filename=self.robot.resource_file) self.robot.set_apiutils(self.apiutil) @@ -66,15 +68,17 @@ class GenerateRobotData: return keys_with_different_values - def get_params(self, string: str): + def get_params(self, test_case: str): # New content - test_case = self.robot.test_cases[string] + # test_case = self.robot.test_cases[string] lines_starting_response = re.findall(r'^\s*\$\{response\}.*', test_case, re.MULTILINE) # If there is more than one line, it means that the test case has several operations, all of them to # create the environment content to execute the last one, which is the correct one to test the Test Case if len(lines_starting_response) > 1: + # The last one corresponds to the execution of the test, the rest corresponds to the initial condition of + # test case... response_to_check = lines_starting_response[-1] else: response_to_check = lines_starting_response[0] @@ -102,8 +106,8 @@ class GenerateRobotData: break else: # the attributes are in the same line - regex = r"\s*\$\{response\}=\s{4}(.*)\n" - matches = re.finditer(regex, string, re.MULTILINE) + regex = r"\s*\$\{response\}=\s{4}(.*)" + matches = re.finditer(regex, response_to_check, re.MULTILINE) request = aux[0].split(' ')[2] # We have two options from here, or the parameters are defined in the same line or the parameters are defined in @@ -115,16 +119,18 @@ class GenerateRobotData: # Get the list of keys params = aux.split(' ')[1:] + print(params) else: - raise Exception(f"Error, unexpected format, received: '{string}'") + raise Exception(f"Error, unexpected format, received: '{response_to_check}'") return request, params def get_step_data(self, test: str): - string = self.robot.get_substring(initial_string=test, final_string=self.suite.name, include=False) + # string = self.robot.get_substring(initial_string=test, final_string=self.suite.name, include=False) + string = self.robot.test_cases[test] # request, params = self.get_params(string=string) - request, params = self.get_params(string=test) + request, params = self.get_params(test_case=string) #self.check_header_parameters(params=params, test=test) diff --git a/doc/analysis/parseapiutilsfile.py b/doc/analysis/parseapiutilsfile.py index 098e8185..fd61be0d 100644 --- a/doc/analysis/parseapiutilsfile.py +++ b/doc/analysis/parseapiutilsfile.py @@ -23,12 +23,13 @@ class ParseApiUtilsFile: index = None for i, item in enumerate(string): if 'response' in item: - regex = "\s{4}\$\{response\}=\s{4}(.*)" + regex = "\s{4}\$\{response\}=\s{4}(POST|GET|PUT|PATCH|DELETE).*" match = re.match(pattern=regex, string=item) if match: verb = match.groups()[0] - elif 'url' in item: + + if 'url' in item: #url = item.split('/')[1] url = self.get_url_request(url=item) @@ -36,7 +37,14 @@ class ParseApiUtilsFile: @staticmethod def get_url_request(url: str) -> list: - regex = r"\s*\.{3}\s*url=\$\{url\}\/(.*)" + # We have two options, the url is defined in the same line of the response or it is defined in the following + # lines with '...' + keys = list() + + if 'response' in url: + url = [x for x in url.split(' ') if 'url' in x][0] + + regex = r"\s*\.*\s*url=\$\{url\}\/(.*)" match = re.match(pattern=regex, string=url) if match: diff --git a/doc/analysis/parserobotfile.py b/doc/analysis/parserobotfile.py index f9000cac..157c8cc8 100644 --- a/doc/analysis/parserobotfile.py +++ b/doc/analysis/parserobotfile.py @@ -5,7 +5,7 @@ from doc.analysis.requests import Requests class ParseRobotFile: - def __init__(self, filename: str, execdir: str): + def __init__(self, filename: str, execdir: str, config_file): self.test_suite = os.path.basename(filename).split('.')[0] with open(filename, 'r') as file: @@ -21,6 +21,8 @@ class ParseRobotFile: self.get_apiutils_path() self.get_test_cases() + self.config_file = config_file + def set_apiutils(self, apiutils): self.apiutils = apiutils @@ -136,8 +138,9 @@ class ParseRobotFile: return new_list def get_request(self, test_name): - print(test_name) - data = Requests(variables=self.variables, apiutils_variables=self.apiutils.variables) + data = Requests(variables=self.variables, + apiutils_variables=self.apiutils.variables, + config_file=self.config_file) description = data.get_description(string=self.test_cases[test_name]) return description diff --git a/doc/analysis/parsevariablesfile.py b/doc/analysis/parsevariablesfile.py new file mode 100644 index 00000000..26838f54 --- /dev/null +++ b/doc/analysis/parsevariablesfile.py @@ -0,0 +1,24 @@ +from os.path import dirname + + +class ParseVariablesFile: + def __init__(self): + folder = dirname(dirname(dirname(__file__))) + filename = f'{folder}/resources/variables.py' + self.variables = dict() + + with open(filename, 'r') as file: + # Read the contents of the file + file_content = file.read() + + file_content = file_content.split('\n') + file_content = [x.split('=') for x in file_content if x is not ''] + + self.variables = {x[0].strip(): x[1].replace("'", "").strip() for x in file_content} + + def get_variable(self, variable: str) -> str: + # We request the variable in the form '${...}' + variable = variable.strip('${}') + value = self.variables[variable] + + return value diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index 7899f8ef..b97bb816 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -1,30 +1,56 @@ import re +import resources.variables class Requests: - def __init__(self, variables, apiutils_variables): + def __init__(self, variables, apiutils_variables, config_file): self.op = { 'Create Entity Selecting Content Type': { - 'positions': [1, 3], + 'positions': [0, 2], 'params': ['filename', 'content_type'] }, 'Create Subscription': { - 'positions': [2, 3], + 'positions': [1, 2], 'params': ['filename', 'content_type'] }, 'Create Or Update Temporal Representation Of Entity Selecting Content Type': { - 'positions': [2, 3], + 'positions': [1, 2], 'params': ['filename', 'content_type'] }, 'Batch Create Entities': { - 'positions': [2], + 'positions': [1], 'params': ['content_type'] }, 'Create Context Source Registration With Return': { - 'positions': [1], + 'positions': [0], 'params': ['filename'] + }, + 'Query Entity': { + 'positions': [1], + 'params': ['context'] + }, + 'Retrieve Subscription': { + 'positions': [], + 'params': [] + }, + 'Query Context Source Registrations With Return': { + 'positions': [], + 'params': [] + }, + 'Query Temporal Representation Of Entities With Return': { + 'positions': [], + 'params': [] + }, + 'Partial Update Entity Attributes': { + 'positions': [2, 3, 4], + 'params': ['filename', "content", "context"] + }, + 'Update Subscription': { + 'positions': [1, 2, 3], + 'params': ['filename', 'content', 'context'] } + } self.description = { 'Create Entity Selecting Content Type': @@ -36,33 +62,101 @@ class Requests: 'Batch Create Entities': Requests.batch_create_entities, 'Create Context Source Registration With Return': - Requests.create_context_source_registration_with_return + Requests.create_context_source_registration_with_return, + 'Query Entity': + Requests.query_entity, + 'Retrieve Subscription': + Requests.retrieve_subscription, + 'Query Context Source Registrations With Return': + Requests.query_context_source_registrations_with_return, + 'Query Temporal Representation Of Entities With Return': + Requests.query_temporal_representation_of_entities_with_return, + 'Partial Update Entity Attributes': + Requests.partial_update_entity_attributes, + 'Update Subscription': + Requests.update_subscription } self.variables = variables self.apiutils_variables = apiutils_variables + self.config_file = config_file def get_description(self, string): keys = self.op.keys() params = dict() - index = None - for k in keys: - index = string.find(k) - if index != -1: - break + # New version + lines_starting_response = re.findall(r'^\s*\$\{response\}.*', string, re.MULTILINE) - pattern = f"^.*{k}.*\n" - lines_starting_with_request = re.findall(pattern, string, re.MULTILINE) - for line in lines_starting_with_request: - data = line.strip().split(" ") - if len(data) == 2: - # We are in multiline definition - params = self.find_attributes_next_line(string=string, position=index, request_name=k) - else: - # The definition of the request is in the same line - params = self.find_attributes_in_the_same_line(request_name=k, params=data[1:]) + # If there is more than one line, it means that the test case has several operations, all of them to + # create the environment content to execute the last one, which is the correct one to test the Test Case + if len(lines_starting_response) > 1: + # The last one corresponds to the execution of the test, the rest corresponds to the initial condition of + # test case... + response_to_check = lines_starting_response[-1] + else: + response_to_check = lines_starting_response[0] + + index = string.find(response_to_check) + aux = string[index:].split('\n') + + params = list() + request = str() + + # Get the list of params of the function, they are the keys + if ' ... ' in aux[1]: + request = aux[0].split(' ')[2] + # We are in the case that the attributes are in following lines + for i in range(1, len(aux)): + if ' ... ' in aux[i]: + regex = '\s{4}\.{3}\s{4}(.*)' + param = re.match(pattern=regex, string=aux[i]) + if aux: + params.append(param.groups()[0]) + else: + break + + #params = self.find_attributes_next_lines(string=string, position=index, request_name=request) + params = self.find_attributes_in_the_same_line(request_name=request, params=params) + else: + # the attributes are in the same line + regex = r"\s*\$\{response\}=\s{4}(.*)" + matches = re.finditer(regex, response_to_check, re.MULTILINE) + request = aux[0].split(' ')[2] + + # We have two options from here, or the parameters are defined in the same line or the parameters are defined in + # following lines, next lines + for match in matches: + # Check that we have 1 group matched + if len(match.groups()) == 1: + aux = match.group(1) + + # Get the list of keys + params = aux.split(' ')[1:] + else: + raise Exception(f"Error, unexpected format, received: '{response_to_check}'") - description = self.description[k](params) + params = self.find_attributes_in_the_same_line(request_name=request, params=params) + + # return request, params + # Previous version + # index = None + # for k in keys: + # index = string.find(k) + # if index != -1: + # break + # + # pattern = f"^.*{k}.*\n" + # lines_starting_with_request = re.findall(pattern, string, re.MULTILINE) + # for line in lines_starting_with_request: + # data = line.strip().split(" ") + # if len(data) == 2: + # # We are in multiline definition + # params = self.find_attributes_next_line(string=string, position=index, request_name=k) + # else: + # # The definition of the request is in the same line + # params = self.find_attributes_in_the_same_line(request_name=k, params=data[1:]) + + description = self.description[request](params) return description def find_attributes_in_the_same_line(self, request_name, params): @@ -70,12 +164,12 @@ class Requests: for i in range(0, len(self.op[request_name]['positions'])): param_position = self.op[request_name]['positions'][i] param_key = self.op[request_name]['params'][i] - param_value = self.get_value(params=params, param_position=param_position) + param_value = self.get_value(params=params, param_position=param_position, param_key=param_key) param[param_key] = param_value return param - def find_attributes_next_line(self, string, position, request_name): + def find_attributes_next_lines(self, string, position, request_name): aux = string[position+len(request_name)+1:].split('\n') params = list() @@ -90,8 +184,8 @@ class Requests: for i in range(0, len(self.op[request_name]['positions'])): print(i) param_position = self.op[request_name]['positions'][i] - 1 - param_value = self.get_value(params=params, param_position=param_position) param_key = self.op[request_name]['params'][i] + param_value = self.get_value(params=params, param_position=param_position, param_key=param_key) param[param_key] = param_value return param @@ -123,13 +217,78 @@ class Requests: else: raise Exception(f"ERROR, expected filename attribute, but received {kwargs}") - def get_value(self, params, param_position): + @staticmethod + def query_entity(kwargs) -> str: + if 'context' in kwargs: + result = f"Request Header['Link'] contain the context {kwargs['context']}" + return result + else: + raise Exception(f"ERROR, expected context attribute, but received {kwargs}") + + @staticmethod + def retrieve_subscription(kwargs) -> str: + return "Request a subscription" + + def query_context_source_registrations_with_return(kwargs) -> str: + return "Request a Context Source Registration with Return" + + def query_temporal_representation_of_entities_with_return(kwargs) -> str: + return "Request a Temporal Representation of Entities with Return" + + def partial_update_entity_attributes(kwargs) -> str: + if 'context' in kwargs and 'content' in kwargs and 'filename' in kwargs: + context = kwargs['context'] + if context == '': + return (f"Request Partial Update Entity Attributes and \n" + f"Header['Content-Type'] set to '{kwargs['content']}' and\n" + f"Payload defined in file '{kwargs['filename']}'") + else: + return (f"Request Partial Update Entity Attributes and \n" + f"Header['Link'] contain the context '{kwargs['context']}' and \n" + f"Header['Content-Type'] set to '{kwargs['content']}' and\n" + f"Payload defined in file '{kwargs['filename']}'") + else: + raise Exception(f"ERROR, expected context attribute, but received {kwargs}") + + def update_subscription(kwargs) -> str: + if 'context' in kwargs and 'content' in kwargs and 'filename' in kwargs: + context = kwargs['context'] + if context == '': + return (f"Request Update Subscription and \n" + f"Header['Content-Type'] set to '{kwargs['content']}' and\n" + f"Payload defined in file '{kwargs['filename']}'") + else: + return (f"Request Update Subscription and \n" + f"Header['Link'] contain the context '{kwargs['context']}' and\n" + f"Header['Content-Type'] set to '{kwargs['content']}' and\n" + f"Payload defined in file '{kwargs['filename']}'") + else: + raise Exception(f"ERROR, expected context attribute, but received {kwargs}") + + def get_value(self, params, param_position, param_key): + try: + data = params[param_position] + except IndexError: + return '' + + if '=' in data: + # The name of the attribute is passed to the function in the form attribute=value + data = data.split('=') + if data[0] != param_key: + raise Exception(f"ERROR, uncontrolled param_key: {params} {param_key}") + + data = data[1] + try: - value = self.variables[params[param_position]] + value = self.variables[data] return value except KeyError: try: - value = self.apiutils_variables[params[param_position]] + value = self.apiutils_variables[data] return value except KeyError: - return params[param_position] + try: + value = self.config_file.get_variable(variable=data) + return value + except KeyError: + return data diff --git a/doc/files/043_01.json b/doc/files/043_01.json index 476e460b..487cbb0a 100644 --- a/doc/files/043_01.json +++ b/doc/files/043_01.json @@ -69,7 +69,7 @@ "teardown": "Batch Delete Entities", "template": null, "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing the type 'https://uri.etsi.org/ngsi-ld/errors/LdContextNotAvailable' and\n Response body containing 'title' element and\n Response Status Code set to 503\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entityOperations/create'\n method set to 'POST'\n Request Header['Content-Type'] set to 'content_type=${CONTENT_TYPE_LD_JSON}' and\n payload set to a list of entities to be created", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entityOperations/create'\n method set to 'POST'\n Request Header['Content-Type'] set to 'application/ld+json' and\n payload set to a list of entities to be created", "http_verb": "POST", "endpoint": "entityOperations/create" }, @@ -91,8 +91,8 @@ } ], "permutations": [ - "when", "endpoint", + "when", "then" ] } \ No newline at end of file diff --git a/doc/files/044_01.json b/doc/files/044_01.json index 515f5ad5..e034de94 100644 --- a/doc/files/044_01.json +++ b/doc/files/044_01.json @@ -1,49 +1,49 @@ { - "tp_id": "TP/NGSI-LD/CB/044_01", - "test_objective": "Verify that PATCH HTTP requests can be done with \"application/merge-patch+json\" as Content-Type", - "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.4", - "config_id": "", - "parent_release": "v1.3.1", - "pics_selection": "PICS_6_3_4", - "keywords": [], - "teardown": "None", - "initial_condition": "with {\n the SUT in the \"initial state\"\n}", - "test_cases": [ - { - "name": "044_01_01 endpoint /entities/{entityId}/attrs/{attrId}", - "permutation_tp_id": "TP/NGSI-LD/CB/044_01_01", - "doc": "Verify that PATCH HTTP requests can be done with \"application/merge-patch+json\" as Content-Type", - "tags": [ - "6_3_4", - "ea-partial-update" - ], - "setup": null, - "teardown": "Delete Entity by Id", - "template": null, - "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 204\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Request Header['Content-Type'] set to 'application/ld+json' and\n payload defined in file: 'vehicle-simple-attributes-sample.jsonld'", - "http_verb": "PATCH", - "endpoint": "entities/{entityId}/attrs/{attributeId}" - }, - { - "name": "044_01_02 endpoint /subscriptions/{subscriptionId}", - "permutation_tp_id": "TP/NGSI-LD/CB/044_01_02", - "doc": "Verify that PATCH HTTP requests can be done with \"application/merge-patch+json\" as Content-Type", - "tags": [ - "6_3_4", - "sub-update" - ], - "setup": null, - "teardown": "Delete Subscription", - "template": null, - "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 204\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{subscription_id}'\n method set to 'PATCH'\n Request Header['Content-Type'] set to 'application/ld+json' and\n payload defined in file: 'subscriptions/subscription-sample.jsonld'", - "http_verb": "PATCH", - "endpoint": "subscriptions/{subscription_id}" - } - ], - "permutations": [ - "endpoint", - "when" - ] + "tp_id": "TP/NGSI-LD/CB/044_01", + "test_objective": "Verify that PATCH HTTP requests can be done with \"application/merge-patch+json\" as Content-Type", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.4", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_6_3_4", + "keywords": [], + "teardown": "None", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "044_01_01 endpoint /entities/{entityId}/attrs/{attrId}", + "permutation_tp_id": "TP/NGSI-LD/CB/044_01_01", + "doc": "Verify that PATCH HTTP requests can be done with \"application/merge-patch+json\" as Content-Type", + "tags": [ + "6_3_4", + "ea-partial-update" + ], + "setup": null, + "teardown": "Delete Entity by Id", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 204\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Request Update Entity Attributes and \nHeader['Link'] contain the context 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld' and \nHeader['Content-Type'] set to 'application/merge-patch+json' and\nPayload defined in file 'vehicle-brandname-fragment.json'", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "044_01_02 endpoint /subscriptions/{subscriptionId}", + "permutation_tp_id": "TP/NGSI-LD/CB/044_01_02", + "doc": "Verify that PATCH HTTP requests can be done with \"application/merge-patch+json\" as Content-Type", + "tags": [ + "6_3_4", + "sub-update" + ], + "setup": null, + "teardown": "Delete Subscription", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 204\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{subscription_id}'\n method set to 'PATCH'\n Request Update Subscription and \nHeader['Link'] contain the context 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld' and \nHeader['Content-Type'] set to 'application/merge-patch+json' and\nPayload defined in file 'subscriptions/fragments/subscription-update-sample.json'", + "http_verb": "PATCH", + "endpoint": "subscriptions/{subscription_id}" + } + ], + "permutations": [ + "when", + "endpoint" + ] } \ No newline at end of file diff --git a/doc/files/044_02.json b/doc/files/044_02.json new file mode 100644 index 00000000..35bb96c5 --- /dev/null +++ b/doc/files/044_02.json @@ -0,0 +1,81 @@ +{ + "tp_id": "TP/NGSI-LD/CB/044_02", + "test_objective": "Verify that on a GET HTTP request if nothing is specified on the Accept header, \"application/json\" is assumed", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.4", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_6_3_4", + "keywords": [], + "teardown": "None", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "044_02_01 endpoint /entities/{entityId}", + "permutation_tp_id": "TP/NGSI-LD/CB/044_02_01", + "doc": "Verify that on a GET HTTP request if nothing is specified on the Accept header, \"application/json\" is assumed (/entities/{entityId})", + "tags": [ + "6_3_4", + "e-query" + ], + "setup": null, + "teardown": "Delete Entity by Id Returning Response", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Header: Content-Type set to application/json and\n Response Header: Link is not Empty and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{id}'\n method set to 'GET'\n Request Header['Link'] contain the context https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld", + "http_verb": "GET", + "endpoint": "entities/{id}" + }, + { + "name": "044_02_02 endpoint /subscriptions/{subscriptionId}", + "permutation_tp_id": "TP/NGSI-LD/CB/044_02_02", + "doc": "Verify that on a GET HTTP request if nothing is specified on the Accept header, \"application/json\" is assumed (/subscriptions/{subscriptionId})", + "tags": [ + "6_3_4", + "sub-retrieve" + ], + "setup": null, + "teardown": "Delete Subscription", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Header: Content-Type set to application/json and\n Response Header: Link is not Empty and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{id}'\n method set to 'GET'\n Request a subscription", + "http_verb": "GET", + "endpoint": "subscriptions/{id}" + }, + { + "name": "044_02_03 endpoint /csourceRegistrations/", + "permutation_tp_id": "TP/NGSI-LD/CB/044_02_03", + "doc": "Verify that on a GET HTTP request if nothing is specified on the Accept header, \"application/json\" is assumed (/csourceRegistrations/)", + "tags": [ + "6_3_4", + "csr-query" + ], + "setup": null, + "teardown": "Delete Context Source Registration", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Header: Content-Type set to application/json and\n Response Header: Link is not Empty and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/csourceRegistrations'\n method set to 'GET'\n Request a Context Source Registration with Return", + "http_verb": "GET", + "endpoint": "csourceRegistrations" + }, + { + "name": "044_02_04 endpoint /temporal/entities", + "permutation_tp_id": "TP/NGSI-LD/CB/044_02_04", + "doc": "Verify that on a GET HTTP request if nothing is specified on the Accept header, \"application/json\" is assumed (/temporal/entities)", + "tags": [ + "6_3_4", + "te-query" + ], + "setup": null, + "teardown": "Delete Temporal Representation Of Entity", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Header: Content-Type set to application/json and\n Response Header: Link is not Empty and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities'\n method set to 'GET'\n Request a Temporal Representation of Entities with Return", + "http_verb": "GET", + "endpoint": "temporal/entities" + } + ], + "permutations": [ + "endpoint", + "when" + ] +} \ No newline at end of file diff --git a/doc/generateDocumentationData.py b/doc/generateDocumentationData.py index 703286fa..e2766416 100644 --- a/doc/generateDocumentationData.py +++ b/doc/generateDocumentationData.py @@ -1,6 +1,5 @@ -from pprint import pprint from doc.analysis.generaterobotdata import GenerateRobotData -import json +from json import dump from os.path import dirname, exists from os import makedirs @@ -8,7 +7,7 @@ if __name__ == "__main__": folder_test_suites = dirname(dirname(__file__)) folder_result_path = f'{folder_test_suites}/doc/results' result_file = f'{folder_result_path}/result.json' - robot_file = f'{folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_01.robot' + robot_file = f'{folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_03.robot' # Check that the folder '/results' exists and if not, create it if not exists(folder_result_path): @@ -20,10 +19,4 @@ if __name__ == "__main__": info = data.get_info() with open(result_file, 'w') as fp: - json.dump(obj=info, indent=4, fp=fp) - - # data = GenerateRobotData(robot_file='../TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001_01.robot', - # execdir='/home/fla/Documents/workspace/bdd/ngsi-ld-test-suite') - # data.parse_robot() - # info = data.get_info() - # pprint(info) + dump(obj=info, indent=4, fp=fp) diff --git a/doc/tests/test_CommonBehaviours.py b/doc/tests/test_CommonBehaviours.py index f29ccf1d..580a6355 100644 --- a/doc/tests/test_CommonBehaviours.py +++ b/doc/tests/test_CommonBehaviours.py @@ -8,9 +8,10 @@ from os import listdir, remove, makedirs class TestCommonBehaviours(TestCase): - def setUp(self) -> None: - self.folder_test_suites = dirname(dirname(dirname(__file__))) - folder_results = f'{self.folder_test_suites}/doc/results' + @classmethod + def setUpClass(cls): + TestCommonBehaviours.folder_test_suites = dirname(dirname(dirname(__file__))) + folder_results = f'{TestCommonBehaviours.folder_test_suites}/doc/results' # Check that the folder '/results' exists and if not, create it if not exists(folder_results): @@ -19,6 +20,9 @@ class TestCommonBehaviours(TestCase): # Delete the /results folder [remove(f'{folder_results}/{x}') for x in listdir(folder_results) if x.startswith('out')] + def setUp(self) -> None: + self.folder_test_suites = dirname(dirname(dirname(__file__))) + def common_function(self, robot_file, expected_value, difference_file): data = GenerateRobotData(robot_file=robot_file, execdir=self.folder_test_suites) @@ -51,3 +55,9 @@ class TestCommonBehaviours(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_044_02(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_02.robot' + expected_value = f'{self.folder_test_suites}/doc/files/044_02.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_044_02.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) -- GitLab From 9bd367529a8b0b8ef9f19b82531c1a42bcbff4c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Thu, 28 Sep 2023 15:49:48 +0200 Subject: [PATCH 2/9] Change the initial process to accept only the name of the robot file without the extensions --- doc/generateDocumentationData.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/doc/generateDocumentationData.py b/doc/generateDocumentationData.py index 10c1f129..1cb4fba4 100644 --- a/doc/generateDocumentationData.py +++ b/doc/generateDocumentationData.py @@ -2,13 +2,16 @@ from doc.analysis.generaterobotdata import GenerateRobotData from json import dump from sys import argv from os.path import dirname, exists -from os import makedirs +from os import makedirs, walk -def create_json_of_robotfile(robot_path_to_be_processed: str, robot_file_to_be_processed: str): + +def create_json_of_robotfile(robot_file_to_be_processed: str): folder_test_suites = dirname(dirname(__file__)) + folder_result_path = f'{folder_test_suites}/doc/results' result_file = f'{folder_result_path}/{robot_file_to_be_processed}.json' - robot_file = f'{folder_test_suites}/TP/NGSI-LD/{robot_path_to_be_processed}/{robot_file_to_be_processed}.robot' + robot_path_to_be_processed, robot_file = find_robot_file(basedir=folder_test_suites, + filename=robot_file_to_be_processed) # Check that the folder '/results' exists and if not, create it if not exists(folder_result_path): @@ -32,9 +35,18 @@ def create_json_of_robotfile(robot_path_to_be_processed: str, robot_file_to_be_p return info +def find_robot_file(basedir: str, filename: str): + filename = f'{filename}.robot' + for root, dirs, files in walk(basedir): + if filename in files: + return root.replace(f'{basedir}/TP/NGSI-LD', ''), f'{root}/{filename}' + + return None, None + + if __name__ == "__main__": + # Call with the folder below /TP/NGSI-LD which contains the robot file with name args[0] args = argv[1:] - robot_path_tbp = args[0] - robot_file_tbp = args[1] - resulting_json = create_json_of_robotfile(robot_path_tbp, robot_file_tbp) + robot_file_tbp = args[0] + resulting_json = create_json_of_robotfile(robot_file_tbp) print("Correctly exiting") -- GitLab From a3a715f9a38a44ca0f9103fb8254f5ee0d24cd68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Thu, 28 Sep 2023 16:30:17 +0200 Subject: [PATCH 3/9] Update the architecture of the python package --- doc/analysis/generaterobotdata.py | 6 +++--- doc/analysis/parserobotfile.py | 4 ++-- doc/analysis/requests.py | 1 - doc/generateDocumentationData.py | 2 +- requirements.txt | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/analysis/generaterobotdata.py b/doc/analysis/generaterobotdata.py index 06b9bc51..c49f19b8 100644 --- a/doc/analysis/generaterobotdata.py +++ b/doc/analysis/generaterobotdata.py @@ -1,8 +1,8 @@ from os.path import dirname from robot.api import TestSuiteBuilder -from doc.analysis.parserobotfile import ParseRobotFile -from doc.analysis.parseapiutilsfile import ParseApiUtilsFile -from doc.analysis.parsevariablesfile import ParseVariablesFile +from analysis.parserobotfile import ParseRobotFile +from analysis.parseapiutilsfile import ParseApiUtilsFile +from analysis.parsevariablesfile import ParseVariablesFile import re diff --git a/doc/analysis/parserobotfile.py b/doc/analysis/parserobotfile.py index 157c8cc8..80a7dada 100644 --- a/doc/analysis/parserobotfile.py +++ b/doc/analysis/parserobotfile.py @@ -1,7 +1,7 @@ import re import os -from doc.analysis.checks import Checks -from doc.analysis.requests import Requests +from analysis.checks import Checks +from analysis.requests import Requests class ParseRobotFile: diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index b97bb816..ef8c61c8 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -1,5 +1,4 @@ import re -import resources.variables class Requests: diff --git a/doc/generateDocumentationData.py b/doc/generateDocumentationData.py index 1cb4fba4..7c97ea6f 100644 --- a/doc/generateDocumentationData.py +++ b/doc/generateDocumentationData.py @@ -1,4 +1,4 @@ -from doc.analysis.generaterobotdata import GenerateRobotData +from analysis.generaterobotdata import GenerateRobotData from json import dump from sys import argv from os.path import dirname, exists diff --git a/requirements.txt b/requirements.txt index 686ff92b..c0fe3567 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ robotframework==6.1.1 robotframework-jsonlibrary==0.5 robotframework-requests==0.9.5 -deepdiff==6.3.1 +deepdiff==6.5.0 prettydiff==0.1.0 robotframework-httpctrl==0.3.1 robotframework-tidy==4.5.0 -- GitLab From b53a381f54b69d83f40a3102b0c5d37ebd5d52c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Thu, 28 Sep 2023 19:17:42 +0200 Subject: [PATCH 4/9] Update doc for 044_03, 044_04, 044_05 --- TP/NGSI-LD/CommonBehaviours/044_04.robot | 12 +-- doc/analysis/generaterobotdata.py | 6 ++ doc/analysis/requests.py | 122 ++++++++++++++++------- doc/files/043_01.json | 4 +- doc/files/044_01.json | 8 +- doc/files/044_02.json | 10 +- doc/files/044_03.json | 116 +++++++++++++++++++++ doc/files/044_04.json | 98 ++++++++++++++++++ doc/files/044_05.json | 67 +++++++++++++ doc/generateDocumentationData.py | 19 ++-- doc/tests/test_CommonBehaviours.py | 21 ++++ 11 files changed, 420 insertions(+), 63 deletions(-) create mode 100644 doc/files/044_03.json create mode 100644 doc/files/044_04.json create mode 100644 doc/files/044_05.json diff --git a/TP/NGSI-LD/CommonBehaviours/044_04.robot b/TP/NGSI-LD/CommonBehaviours/044_04.robot index b0670b2a..cb71c747 100644 --- a/TP/NGSI-LD/CommonBehaviours/044_04.robot +++ b/TP/NGSI-LD/CommonBehaviours/044_04.robot @@ -16,7 +16,7 @@ ${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld *** Test Cases *** -044_04_01_endpoint get /entities/{entityId} +044_04_01 endpoint get /entities/{entityId} [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /entities/{entityId}) [Tags] e-query 6_3_4 ${entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -29,7 +29,7 @@ ${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld Check Response Status Code ${status_code} ${response.status_code} [Teardown] Delete Entity by Id Returning Response ${entity_id} -044_04_02_endpoint get /subscriptions/{subscriptionId} +044_04_02 endpoint get /subscriptions/{subscriptionId} [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /subscriptions/{subscriptionId}) [Tags] sub-retrieve 6_3_4 ${id}= Generate Random Entity Id ${subscription_id_prefix} @@ -39,19 +39,19 @@ ${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld Check Response Status Code ${status_code} ${response.status_code} [Teardown] Delete Subscription ${id} -044_04_03_endpoint get /csourceRegistrations/ +044_04_03 endpoint get /csourceRegistrations/ [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /csourceRegistrations/) [Tags] csr-query 6_3_4 ${response}= Query Context Source Registrations With Return type=Building accept=${accept} Check Response Status Code ${status_code} ${response.status_code} -044_04_04_endpoint get /csourceSubscriptions/ +044_04_04 endpoint get /csourceSubscriptions/ [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /csourceSubscriptions/) [Tags] csrsub-query - Query Context Source Registration Subscriptions accept=${accept} + ${response}= Query Context Source Registration Subscriptions accept=${accept} Check Response Status Code ${status_code} ${response.status_code} -044_04_05_endpoint get /temporal/entities +044_04_05 endpoint get /temporal/entities [Documentation] Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /temporal/entities) [Tags] te-query 6_3_4 ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Vehicle diff --git a/doc/analysis/generaterobotdata.py b/doc/analysis/generaterobotdata.py index c49f19b8..052d648b 100644 --- a/doc/analysis/generaterobotdata.py +++ b/doc/analysis/generaterobotdata.py @@ -8,6 +8,9 @@ import re class GenerateRobotData: def __init__(self, robot_file: str, execdir: str): + self.robot_file = robot_file + self.execdir = execdir + self.config_variables = ParseVariablesFile() self.robot = ParseRobotFile(filename=robot_file, execdir=execdir, config_file=self.config_variables) self.apiutil = ParseApiUtilsFile(filename=self.robot.resource_file) @@ -46,6 +49,9 @@ class GenerateRobotData: self.base_TP_id = str() def get_info(self): + self.test_suite['robotpath'] = (self.robot_file.replace(f'{self.execdir}/TP/NGSI-LD/', '') + .replace(f'/{self.robot.test_suite}.robot', '')) + self.test_suite['robotfile'] = self.robot.test_suite return self.test_suite def parse_robot(self): diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index ef8c61c8..c935361e 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -25,16 +25,16 @@ class Requests: 'params': ['filename'] }, 'Query Entity': { - 'positions': [1], - 'params': ['context'] + 'positions': [1, 1], + 'params': ['context', 'accept'] }, 'Retrieve Subscription': { - 'positions': [], - 'params': [] + 'positions': [1], + 'params': ['accept'] }, 'Query Context Source Registrations With Return': { - 'positions': [], - 'params': [] + 'positions': [0, 1], + 'params': ["type", "accept"] }, 'Query Temporal Representation Of Entities With Return': { 'positions': [], @@ -48,9 +48,17 @@ class Requests: 'positions': [1, 2, 3], 'params': ['filename', 'content', 'context'] + }, + 'Query Context Source Registration Subscriptions': { + 'positions': [0], + 'params': ['accept'] + }, + 'Query Temporal Representation Of Entities': { + 'positions': [0, 1, 2, 3], + 'params': ['entity_types', 'timerel', 'timeAt', 'accept'] } - } + self.description = { 'Create Entity Selecting Content Type': Requests.create_entity_selecting_content_type, @@ -73,8 +81,13 @@ class Requests: 'Partial Update Entity Attributes': Requests.partial_update_entity_attributes, 'Update Subscription': - Requests.update_subscription + Requests.update_subscription, + 'Query Context Source Registration Subscriptions': + Requests.query_context_source_registration_subscriptions, + 'Query Temporal Representation Of Entities': + Requests.query_temporal_representation_of_entities } + self.variables = variables self.apiutils_variables = apiutils_variables self.config_file = config_file @@ -136,25 +149,6 @@ class Requests: params = self.find_attributes_in_the_same_line(request_name=request, params=params) - # return request, params - # Previous version - # index = None - # for k in keys: - # index = string.find(k) - # if index != -1: - # break - # - # pattern = f"^.*{k}.*\n" - # lines_starting_with_request = re.findall(pattern, string, re.MULTILINE) - # for line in lines_starting_with_request: - # data = line.strip().split(" ") - # if len(data) == 2: - # # We are in multiline definition - # params = self.find_attributes_next_line(string=string, position=index, request_name=k) - # else: - # # The definition of the request is in the same line - # params = self.find_attributes_in_the_same_line(request_name=k, params=data[1:]) - description = self.description[request](params) return description @@ -218,18 +212,38 @@ class Requests: @staticmethod def query_entity(kwargs) -> str: - if 'context' in kwargs: + result = '' + if 'context' in kwargs and kwargs['context'] != '': result = f"Request Header['Link'] contain the context {kwargs['context']}" - return result - else: + + if 'accept' in kwargs: + result = f"{result}\nHeader['Accept'] set to {kwargs['accept']}" + + if 'context' not in kwargs and 'accept' not in kwargs: raise Exception(f"ERROR, expected context attribute, but received {kwargs}") + return result + @staticmethod def retrieve_subscription(kwargs) -> str: - return "Request a subscription" + if 'accept' in kwargs: + return f"Request a subscription\nHeader['Accept'] set to '{kwargs['accept']}'" + else: + return "Request a subscription" def query_context_source_registrations_with_return(kwargs) -> str: - return "Request a Context Source Registration with Return" + if 'type' in kwargs and 'accept' in kwargs: + result = "Request a Context Source Registration with Return" + + if kwargs['type'] != '': + result = f"{result}\nEntity Type set to '{kwargs['type']}'" + + if kwargs['accept'] != '': + result = f"{result}\nHeader['Accept'] set to '{kwargs['accept']}'" + else: + result = "Request a Context Source Registration with Return" + + return result def query_temporal_representation_of_entities_with_return(kwargs) -> str: return "Request a Temporal Representation of Entities with Return" @@ -264,19 +278,51 @@ class Requests: else: raise Exception(f"ERROR, expected context attribute, but received {kwargs}") + @staticmethod + def query_context_source_registration_subscriptions(kwargs) -> str: + if 'accept' in kwargs: + return (f"Request Context Source Registration Subscriptions\n" + f"Header['Accept'] set to '{kwargs['accept']}'") + else: + raise Exception(f"ERROR, expected accept attribute, but received {kwargs}") + + @staticmethod + def query_temporal_representation_of_entities(kwargs) -> str: + expected_parameters = ['entity_types', 'timerel', 'timeAt', 'accept'] + result = [x for x in expected_parameters if x not in kwargs] + + if len(result) == 0: + response = ("Response containing:\n" + f" * Entity-Type is equal to '{kwargs['entity_types']}'\n" + f" * timeRel is equal to '{kwargs['timerel']}'\n" + f" * timeAt is equal to '{kwargs['timeAt']}'\n" + f" * Accept is equal to '{kwargs['accept']}'") + return response + else: + raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are " + f"'{expected_parameters}', but received: {kwargs}") + def get_value(self, params, param_position, param_key): - try: - data = params[param_position] - except IndexError: - return '' + data = [x for x in params if f'{param_key}=' in x] - if '=' in data: + if len(data) == 1: # The name of the attribute is passed to the function in the form attribute=value + data = data[0] data = data.split('=') if data[0] != param_key: - raise Exception(f"ERROR, uncontrolled param_key: {params} {param_key}") + return '' data = data[1] + elif len(data) == 0: + # There is no attribute=something therefore we have to apply the position + try: + data = params[param_position] + + # Workaround + if 'accept' in data and param_key != 'accept': + data = '' + except IndexError: + return '' try: value = self.variables[data] diff --git a/doc/files/043_01.json b/doc/files/043_01.json index 487cbb0a..05efa025 100644 --- a/doc/files/043_01.json +++ b/doc/files/043_01.json @@ -94,5 +94,7 @@ "endpoint", "when", "then" - ] + ], + "robotpath": "CommonBehaviours", + "robotfile": "043" } \ No newline at end of file diff --git a/doc/files/044_01.json b/doc/files/044_01.json index e034de94..e9ee7848 100644 --- a/doc/files/044_01.json +++ b/doc/files/044_01.json @@ -21,7 +21,7 @@ "teardown": "Delete Entity by Id", "template": null, "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 204\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Request Update Entity Attributes and \nHeader['Link'] contain the context 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld' and \nHeader['Content-Type'] set to 'application/merge-patch+json' and\nPayload defined in file 'vehicle-brandname-fragment.json'", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Request Partial Update Entity Attributes and \nHeader['Link'] contain the context 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld' and \nHeader['Content-Type'] set to 'application/merge-patch+json' and\nPayload defined in file 'vehicle-brandname-fragment.json'", "http_verb": "PATCH", "endpoint": "entities/{entityId}/attrs/{attributeId}" }, @@ -37,7 +37,7 @@ "teardown": "Delete Subscription", "template": null, "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 204\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{subscription_id}'\n method set to 'PATCH'\n Request Update Subscription and \nHeader['Link'] contain the context 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld' and \nHeader['Content-Type'] set to 'application/merge-patch+json' and\nPayload defined in file 'subscriptions/fragments/subscription-update-sample.json'", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{subscription_id}'\n method set to 'PATCH'\n Request Update Subscription and \nHeader['Link'] contain the context 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld' and\nHeader['Content-Type'] set to 'application/merge-patch+json' and\nPayload defined in file 'subscriptions/fragments/subscription-update-sample.json'", "http_verb": "PATCH", "endpoint": "subscriptions/{subscription_id}" } @@ -45,5 +45,7 @@ "permutations": [ "when", "endpoint" - ] + ], + "robotpath": "CommonBehaviours", + "robotfile": "044_01" } \ No newline at end of file diff --git a/doc/files/044_02.json b/doc/files/044_02.json index 35bb96c5..c81d0211 100644 --- a/doc/files/044_02.json +++ b/doc/files/044_02.json @@ -21,7 +21,7 @@ "teardown": "Delete Entity by Id Returning Response", "template": null, "then": "then {\n the SUT sends a valid Response containing:\n Response Header: Content-Type set to application/json and\n Response Header: Link is not Empty and\n Response Status Code set to 200\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{id}'\n method set to 'GET'\n Request Header['Link'] contain the context https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{id}'\n method set to 'GET'\n Request Header['Link'] contain the context https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld\nHeader['Accept'] set to */*", "http_verb": "GET", "endpoint": "entities/{id}" }, @@ -37,7 +37,7 @@ "teardown": "Delete Subscription", "template": null, "then": "then {\n the SUT sends a valid Response containing:\n Response Header: Content-Type set to application/json and\n Response Header: Link is not Empty and\n Response Status Code set to 200\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{id}'\n method set to 'GET'\n Request a subscription", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{id}'\n method set to 'GET'\n Request a subscription\nHeader['Accept'] set to '*/*'", "http_verb": "GET", "endpoint": "subscriptions/{id}" }, @@ -53,7 +53,7 @@ "teardown": "Delete Context Source Registration", "template": null, "then": "then {\n the SUT sends a valid Response containing:\n Response Header: Content-Type set to application/json and\n Response Header: Link is not Empty and\n Response Status Code set to 200\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/csourceRegistrations'\n method set to 'GET'\n Request a Context Source Registration with Return", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/csourceRegistrations'\n method set to 'GET'\n Request a Context Source Registration with Return\nEntity Type set to 'Vehicle'\nHeader['Accept'] set to '*/*'", "http_verb": "GET", "endpoint": "csourceRegistrations" }, @@ -77,5 +77,7 @@ "permutations": [ "endpoint", "when" - ] + ], + "robotpath": "CommonBehaviours", + "robotfile": "044_02" } \ No newline at end of file diff --git a/doc/files/044_03.json b/doc/files/044_03.json new file mode 100644 index 00000000..01db0ed9 --- /dev/null +++ b/doc/files/044_03.json @@ -0,0 +1,116 @@ +{ + "tp_id": "TP/NGSI-LD/CB/044_03", + "test_objective": "Verify throwing 415 HTTP status code (Unsupported Media Type) if \"Content-Type\" header is not \"application/json\" or \"application/ld+json\"", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.4", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_6_3_4", + "keywords": [], + "teardown": "None", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "044_03_01 endpoint patch /entities/{entityId}/attrs/{attrId}", + "permutation_tp_id": "TP/NGSI-LD/CB/044_03_01", + "doc": "Verify throwing 415 HTTP status code (Unsupported Media Type) if \"Content-Type\" header is not \"application/json\" or \"application/ld+json\" (patch /entities/{entityId}/attrs/{attrId})", + "tags": [ + "6_3_4", + "ea-partial-update" + ], + "setup": null, + "teardown": "Delete Entity by Id Returning Response", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 415\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Request Partial Update Entity Attributes and \nHeader['Content-Type'] set to 'application/xml' and\nPayload defined in file 'vehicle-brandname-fragment.jsonld'", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "044_03_02 endpoint patch /subscriptions/{subscriptionId}", + "permutation_tp_id": "TP/NGSI-LD/CB/044_03_02", + "doc": "Verify throwing 415 HTTP status code (Unsupported Media Type) if \"Content-Type\" header is not \"application/json\" or \"application/ld+json\" (patch /subscriptions/{subscriptionId})", + "tags": [ + "6_3_4", + "sub-update" + ], + "setup": null, + "teardown": "Delete Subscription", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 415\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{subscription_id}'\n method set to 'PATCH'\n Request Update Subscription and \nHeader['Content-Type'] set to 'application/xml' and\nPayload defined in file 'csourceSubscriptions/fragments/subscription-update-sample.jsonld'", + "http_verb": "PATCH", + "endpoint": "subscriptions/{subscription_id}" + }, + { + "name": "044_03_03 endpoint post /entities/", + "permutation_tp_id": "TP/NGSI-LD/CB/044_03_03", + "doc": "Verify throwing 415 HTTP status code (Unsupported Media Type) if \"Content-Type\" header is not \"application/json\" or \"application/ld+json\" (post /entities/)", + "tags": [ + "6_3_4", + "e-create" + ], + "setup": null, + "teardown": "Delete Entity by Id", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 415\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'POST'\n Request Header['Content-Type'] set to 'application/xml' and\n payload defined in file: 'building-simple-attributes-sample.jsonld'", + "http_verb": "POST", + "endpoint": "entities/" + }, + { + "name": "044_03_04 endpoint post /subscriptions/", + "permutation_tp_id": "TP/NGSI-LD/CB/044_03_04", + "doc": "Verify throwing 415 HTTP status code (Unsupported Media Type) if \"Content-Type\" header is not \"application/json\" or \"application/ld+json\" (post /subscriptions/)", + "tags": [ + "6_3_4", + "sub-create" + ], + "setup": null, + "teardown": "Delete Subscription", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 415\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/'\n method set to 'POST'\n Request Header['Content-Type'] set to 'application/xml' and\n payload defined in file: 'csourceSubscriptions/subscription-sample.jsonld'", + "http_verb": "POST", + "endpoint": "subscriptions/" + }, + { + "name": "044_03_05 endpoint post /entityOperations/create", + "permutation_tp_id": "TP/NGSI-LD/CB/044_03_05", + "doc": "Verify throwing 415 HTTP status code (Unsupported Media Type) if \"Content-Type\" header is not \"application/json\" or \"application/ld+json\" (post /entityOperations/create)", + "tags": [ + "6_3_4", + "be-create" + ], + "setup": null, + "teardown": "Batch Delete Entities", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 415\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entityOperations/create'\n method set to 'POST'\n Request Header['Content-Type'] set to 'application/xml' and\n payload set to a list of entities to be created", + "http_verb": "POST", + "endpoint": "entityOperations/create" + }, + { + "name": "044_03_06 endpoint post /temporal/entities/", + "permutation_tp_id": "TP/NGSI-LD/CB/044_03_06", + "doc": "Verify throwing 415 HTTP status code (Unsupported Media Type) if \"Content-Type\" header is not \"application/json\" or \"application/ld+json\" (post /temporal/entities/)", + "tags": [ + "6_3_4", + "te-create" + ], + "setup": null, + "teardown": "Delete Temporal Representation Of Entity", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 415\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities'\n method set to 'POST'\n Request Header['Content-Type'] set to 'application/xml' and\n payload defined in file: 'vehicle-temporal-representation-sample.jsonld'", + "http_verb": "POST", + "endpoint": "temporal/entities" + } + ], + "permutations": [ + "endpoint", + "http_verb", + "when" + ], + "robotpath": "CommonBehaviours", + "robotfile": "044_03" +} \ No newline at end of file diff --git a/doc/files/044_04.json b/doc/files/044_04.json new file mode 100644 index 00000000..bd14baf7 --- /dev/null +++ b/doc/files/044_04.json @@ -0,0 +1,98 @@ +{ + "tp_id": "TP/NGSI-LD/CB/044_04", + "test_objective": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header does not imply \"application/json\" nor \"application/ld+json\"", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.4", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_6_3_4", + "keywords": [], + "teardown": "None", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "044_04_01 endpoint get /entities/{entityId}", + "permutation_tp_id": "TP/NGSI-LD/CB/044_04_01", + "doc": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header does not imply \"application/json\" nor \"application/ld+json\" (get /entities/{entityId})", + "tags": [ + "6_3_4", + "e-query" + ], + "setup": null, + "teardown": "Delete Entity by Id Returning Response", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 406\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{id}'\n method set to 'GET'\n \nHeader['Accept'] set to application/xml", + "http_verb": "GET", + "endpoint": "entities/{id}" + }, + { + "name": "044_04_02 endpoint get /subscriptions/{subscriptionId}", + "permutation_tp_id": "TP/NGSI-LD/CB/044_04_02", + "doc": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header does not imply \"application/json\" nor \"application/ld+json\" (get /subscriptions/{subscriptionId})", + "tags": [ + "6_3_4", + "sub-retrieve" + ], + "setup": null, + "teardown": "Delete Subscription", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 406\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{id}'\n method set to 'GET'\n Request a subscription\nHeader['Accept'] set to 'application/xml'", + "http_verb": "GET", + "endpoint": "subscriptions/{id}" + }, + { + "name": "044_04_03 endpoint get /csourceRegistrations/", + "permutation_tp_id": "TP/NGSI-LD/CB/044_04_03", + "doc": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header does not imply \"application/json\" nor \"application/ld+json\" (get /csourceRegistrations/)", + "tags": [ + "6_3_4", + "csr-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 406\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/csourceRegistrations'\n method set to 'GET'\n Request a Context Source Registration with Return\nEntity Type set to 'Building'\nHeader['Accept'] set to 'application/xml'", + "http_verb": "GET", + "endpoint": "csourceRegistrations" + }, + { + "name": "044_04_04 endpoint get /csourceSubscriptions/", + "permutation_tp_id": "TP/NGSI-LD/CB/044_04_04", + "doc": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header does not imply \"application/json\" nor \"application/ld+json\" (get /csourceSubscriptions/)", + "tags": [ + "csrsub-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 406\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/csourceSubscriptions'\n method set to 'GET'\n Request Context Source Registration Subscriptions\nHeader['Accept'] set to 'application/xml'", + "http_verb": "GET", + "endpoint": "csourceSubscriptions" + }, + { + "name": "044_04_05 endpoint get /temporal/entities", + "permutation_tp_id": "TP/NGSI-LD/CB/044_04_05", + "doc": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header does not imply \"application/json\" nor \"application/ld+json\" (get /temporal/entities)", + "tags": [ + "6_3_4", + "te-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 406\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities'\n method set to 'GET'\n Response containing:\n * Entity-Type is equal to '${entity_types_to_be_retrieved}'\n * timeRel is equal to 'after'\n * timeAt is equal to '2020-08-01T12:05:00Z'\n * Accept is equal to 'application/xml'", + "http_verb": "GET", + "endpoint": "temporal/entities" + } + ], + "permutations": [ + "when", + "endpoint" + ], + "robotpath": "CommonBehaviours", + "robotfile": "044_04" +} \ No newline at end of file diff --git a/doc/files/044_05.json b/doc/files/044_05.json new file mode 100644 index 00000000..eb808692 --- /dev/null +++ b/doc/files/044_05.json @@ -0,0 +1,67 @@ +{ + "tp_id": "TP/NGSI-LD/CB/044_05", + "test_objective": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header is \"application/geo+json\" for operations different than \"Retrieve Entity\" and \"Query Entity\"", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.4", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_6_3_4", + "keywords": [], + "teardown": "None", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "044_05_01 Retrieve subscription by id", + "permutation_tp_id": "TP/NGSI-LD/CB/044_05_01", + "doc": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header does not imply \"application/json\" nor \"application/ld+json\" (get /subscriptions/{subscriptionId})", + "tags": [ + "6_3_4", + "sub-retrieve" + ], + "setup": null, + "teardown": "Delete Subscription", + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 406\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/{id}'\n method set to 'GET'\n Request a subscription\nHeader['Accept'] set to 'application/geo+json'", + "http_verb": "GET", + "endpoint": "subscriptions/{id}" + }, + { + "name": "044_05_02 Query temporal entities", + "permutation_tp_id": "TP/NGSI-LD/CB/044_05_02", + "doc": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header does not imply \"application/json\" nor \"application/ld+json\" (get /temporal/entities)", + "tags": [ + "6_3_4", + "te-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 406\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities'\n method set to 'GET'\n Response containing:\n * Entity-Type is equal to '${entity_types_to_be_retrieved}'\n * timeRel is equal to 'after'\n * timeAt is equal to '2020-08-01T12:05:00Z'\n * Accept is equal to 'application/geo+json'", + "http_verb": "GET", + "endpoint": "temporal/entities" + }, + { + "name": "044_05_03 Query context source registration", + "permutation_tp_id": "TP/NGSI-LD/CB/044_05_03", + "doc": "Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the \"Accept\" header does not imply \"application/json\" nor \"application/ld+json\" (get /csourceRegistrations)", + "tags": [ + "6_3_4", + "csr-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Status Code set to 406\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/csourceRegistrations'\n method set to 'GET'\n Request a Context Source Registration with Return\nEntity Type set to 'Building'\nHeader['Accept'] set to 'application/geo+json'", + "http_verb": "GET", + "endpoint": "csourceRegistrations" + } + ], + "permutations": [ + "endpoint", + "when" + ], + "robotpath": "CommonBehaviours", + "robotfile": "044_05" +} \ No newline at end of file diff --git a/doc/generateDocumentationData.py b/doc/generateDocumentationData.py index 7c97ea6f..fc46923f 100644 --- a/doc/generateDocumentationData.py +++ b/doc/generateDocumentationData.py @@ -17,17 +17,14 @@ def create_json_of_robotfile(robot_file_to_be_processed: str): if not exists(folder_result_path): makedirs(folder_result_path) - try: - data = GenerateRobotData(robot_file=robot_file, execdir=folder_test_suites) - data.parse_robot() - info = data.get_info() - except Exception as e: - print("WHILE GENERATING ROBOT DATA:", e) - info = dict() - info["error_while_parsing"] = True - - info["robotpath"] = robot_path_to_be_processed - info["robotfile"] = robot_file_to_be_processed + #try: + data = GenerateRobotData(robot_file=robot_file, execdir=folder_test_suites) + data.parse_robot() + info = data.get_info() + #except Exception as e: + # print("WHILE GENERATING ROBOT DATA:", e) + # info = dict() + # info["error_while_parsing"] = True with open(result_file, 'w') as fp: dump(obj=info, indent=2, fp=fp) diff --git a/doc/tests/test_CommonBehaviours.py b/doc/tests/test_CommonBehaviours.py index 580a6355..88806aa4 100644 --- a/doc/tests/test_CommonBehaviours.py +++ b/doc/tests/test_CommonBehaviours.py @@ -61,3 +61,24 @@ class TestCommonBehaviours(TestCase): difference_file = f'{self.folder_test_suites}/doc/results/out_044_02.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_044_03(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_03.robot' + expected_value = f'{self.folder_test_suites}/doc/files/044_03.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_044_03.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_044_04(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_04.robot' + expected_value = f'{self.folder_test_suites}/doc/files/044_04.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_044_04.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_044_05(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_05.robot' + expected_value = f'{self.folder_test_suites}/doc/files/044_05.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_044_05.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) -- GitLab From 3991463c9bbb5683ec48b32c757c3f3479dbe564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Thu, 28 Sep 2023 20:19:07 +0200 Subject: [PATCH 5/9] Adding 024_01, 024_02, 027_01, and 027_02 --- .../{027_01_01.robot => 027_01.robot} | 2 +- .../{027_01_02.robot => 027_02.robot} | 2 +- .../{024_01_01.robot => 024_01.robot} | 2 +- .../{024_01_02.robot => 024_02.robot} | 2 +- doc/analysis/generaterobotdata.py | 6 +- doc/analysis/parserobotfile.py | 6 +- doc/analysis/requests.py | 35 +++++++++- doc/files/024_01.json | 35 ++++++++++ doc/files/024_02.json | 35 ++++++++++ doc/files/027_01.json | 35 ++++++++++ doc/files/027_02.json | 35 ++++++++++ doc/files/{ => CommonBehaviours}/043_01.json | 0 doc/files/{ => CommonBehaviours}/044_01.json | 0 doc/files/{ => CommonBehaviours}/044_02.json | 0 doc/files/{ => CommonBehaviours}/044_03.json | 0 doc/files/{ => CommonBehaviours}/044_04.json | 0 doc/files/{ => CommonBehaviours}/044_05.json | 0 doc/tests/test_CommonBehaviours.py | 12 ++-- .../test_ContextInformation_Consumption.py | 70 +++++++++++++++++++ 19 files changed, 262 insertions(+), 15 deletions(-) rename TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/{027_01_01.robot => 027_01.robot} (95%) rename TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/{027_01_02.robot => 027_02.robot} (95%) rename TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/{024_01_01.robot => 024_01.robot} (95%) rename TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/{024_01_02.robot => 024_02.robot} (96%) create mode 100644 doc/files/024_01.json create mode 100644 doc/files/024_02.json create mode 100644 doc/files/027_01.json create mode 100644 doc/files/027_02.json rename doc/files/{ => CommonBehaviours}/043_01.json (100%) rename doc/files/{ => CommonBehaviours}/044_01.json (100%) rename doc/files/{ => CommonBehaviours}/044_02.json (100%) rename doc/files/{ => CommonBehaviours}/044_03.json (100%) rename doc/files/{ => CommonBehaviours}/044_04.json (100%) rename doc/files/{ => CommonBehaviours}/044_05.json (100%) create mode 100644 doc/tests/test_ContextInformation_Consumption.py diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01.robot similarity index 95% rename from TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01_01.robot rename to TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01.robot index aaeb8c8c..365f40cc 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01.robot @@ -16,7 +16,7 @@ ${filename}= building-simple-attributes-sample.json *** Test Cases *** -Retrieve Detailed Representation Of Available Attribute Without Context +027_01_01 Retrieve Detailed Representation Of Available Attribute Without Context [Documentation] Check that you cannot retrieve a detailed representation of an unknown NGSI-LD attribute [Tags] ed-attr 5_7_10 ${response}= Retrieve Attribute attribute_name=airQualityLevel diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_02.robot similarity index 95% rename from TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01_02.robot rename to TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_02.robot index 5c3c7b09..5e8ef772 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_02.robot @@ -17,7 +17,7 @@ ${expectation_file}= types/expectations/attribute-027-01-expectation.json *** Test Cases *** -Retrieve Detailed Representation Of Available Attribute +027_02_01 Retrieve Detailed Representation Of Available Attribute [Documentation] Check that you can retrieve a list with a detailed representation of NGSI-LD attributes [Tags] ed-attr 5_7_10 ${response}= Retrieve Attribute attribute_name=airQualityLevel context=${ngsild_test_suite_context} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01.robot similarity index 95% rename from TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01_01.robot rename to TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01.robot index e9544039..32b3781a 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01.robot @@ -16,7 +16,7 @@ ${filename}= building-simple-attributes-sample.json *** Test Cases *** -Retrieve Detailed Representation Of Available Entity Type Without Context +024_01_01 Retrieve Detailed Representation Of Available Entity Type Without Context [Documentation] Check that you cannot retrieve a detailed representation of an unknown NGSI-LD entity type [Tags] ed-type 5_7_7 ${response}= Retrieve Entity Type type=Building diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_02.robot similarity index 96% rename from TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01_02.robot rename to TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_02.robot index e147d6cc..35b58a15 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_02.robot @@ -17,7 +17,7 @@ ${expectation_file}= types/expectations/entity-type-info-024-01-expectati *** Test Cases *** -Retrieve Detailed Representation Of Available Entity Type +024_02_01 Retrieve Detailed Representation Of Available Entity Type [Documentation] Check that you can retrieve a detailed representation of a specified NGSI-LD entity type [Tags] ed-type 5_7_7 ${response}= Retrieve Entity Type type=Building context=${ngsild_test_suite_context} diff --git a/doc/analysis/generaterobotdata.py b/doc/analysis/generaterobotdata.py index 052d648b..384e15a4 100644 --- a/doc/analysis/generaterobotdata.py +++ b/doc/analysis/generaterobotdata.py @@ -26,7 +26,9 @@ class GenerateRobotData: self.identifier = { 'ContextInformation': 'CI', 'CommonBehaviours': 'CB', - 'Consumption': 'Cons', + 'Consumption': 'CONS', + 'Discovery/RetrieveAvailableAttributeInformation': 'DISC', + 'Discovery/RetrieveAvailableEntityTypeInformation': 'DISC', 'Entity/RetrieveEntity': 'E', 'Entities/CreateEntity': 'E', 'Provision': 'Prov' @@ -261,7 +263,7 @@ class GenerateRobotData: 'config_id': '', 'parent_release': version, 'pics_selection': pics, - 'keywords': list(self.suite.keywords), + 'keywords': [str(x) for x in self.suite.keywords], 'teardown': str(self.suite.teardown), 'initial_condition': self.suite.setup, 'test_cases': list() diff --git a/doc/analysis/parserobotfile.py b/doc/analysis/parserobotfile.py index 80a7dada..2f269074 100644 --- a/doc/analysis/parserobotfile.py +++ b/doc/analysis/parserobotfile.py @@ -101,7 +101,11 @@ class ParseRobotFile: for i in range(0, len(indexes)-1): self.test_cases[self.test_case_names[i]] = string[indexes[i]:indexes[i+1]] - self.test_cases[self.test_case_names[-1]] = string[indexes[-1]:] + try: + self.test_cases[self.test_case_names[-1]] = string[indexes[-1]:] + except IndexError: + raise Exception(f"ERROR, List index out of range, " + f"probably the name of the Test Case is not following the pattern '{pattern}'") def get_checks(self, test_name, apiutils): data = Checks() diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index c935361e..05d2012d 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -56,9 +56,16 @@ class Requests: 'Query Temporal Representation Of Entities': { 'positions': [0, 1, 2, 3], 'params': ['entity_types', 'timerel', 'timeAt', 'accept'] + }, + 'Retrieve Attribute': { + 'positions': [0], + 'params': ['attribute_name'] + }, + 'Retrieve Entity Type': { + 'positions': [0, 1], + 'params': ['type', 'context'] } } - self.description = { 'Create Entity Selecting Content Type': Requests.create_entity_selecting_content_type, @@ -85,9 +92,14 @@ class Requests: 'Query Context Source Registration Subscriptions': Requests.query_context_source_registration_subscriptions, 'Query Temporal Representation Of Entities': - Requests.query_temporal_representation_of_entities + Requests.query_temporal_representation_of_entities, + 'Retrieve Attribute': + Requests.retrieve_attribute, + 'Retrieve Entity Type': + Requests.retrieve_entity_type } + self.variables = variables self.apiutils_variables = apiutils_variables self.config_file = config_file @@ -302,6 +314,25 @@ class Requests: raise Exception(f"ERROR, unexpected attribute '{result}', the attributes expected are " f"'{expected_parameters}', but received: {kwargs}") + @staticmethod + def retrieve_attribute(kwargs) -> str: + if 'attribute_name' in kwargs: + return f"Retrieve Attribute with attributeName set to '{kwargs['attribute_name']}'" + + @staticmethod + def retrieve_entity_type(kwargs) -> str: + result = "Retrieve Entity Type" + if 'type' in kwargs: + result = f"{result}, with type set to '{kwargs['type']}'" + + if 'context' in kwargs and kwargs['context'] != '': + result = f"{result}, with Header['Link'] containing '{kwargs['context']}'" + + if 'type' not in kwargs or 'context' not in kwargs: + raise Exception(f"ERROR, expected type or context attributes, received '{kwargs}'") + + return result + def get_value(self, params, param_position, param_key): data = [x for x in params if f'{param_key}=' in x] diff --git a/doc/files/024_01.json b/doc/files/024_01.json new file mode 100644 index 00000000..dd8ddea6 --- /dev/null +++ b/doc/files/024_01.json @@ -0,0 +1,35 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/DISC/024_01", + "test_objective": "Check that you cannot retrieve a detailed representation of an unknown NGSI-LD entity type", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.7", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_7", + "keywords": [ + "Setup Initial Entities", + "Delete Initial Entities" + ], + "teardown": "Delete Initial Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "024_01_01 Retrieve Detailed Representation Of Available Entity Type Without Context", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/DISC/024_01_01", + "doc": "Check that you cannot retrieve a detailed representation of an unknown NGSI-LD entity type", + "tags": [ + "5_7_7", + "ed-type" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing the type 'https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound' and\n Response body containing 'title' element and\n Response Status Code set to 404\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/types/{type}'\n method set to 'GET'\n Retrieve Entity Type, with type set to 'Building'", + "http_verb": "GET", + "endpoint": "types/{type}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation", + "robotfile": "024_01" +} \ No newline at end of file diff --git a/doc/files/024_02.json b/doc/files/024_02.json new file mode 100644 index 00000000..e2a306fb --- /dev/null +++ b/doc/files/024_02.json @@ -0,0 +1,35 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/DISC/024_02", + "test_objective": "Check that you can retrieve a detailed representation of a specified NGSI-LD entity type", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.7", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_7", + "keywords": [ + "Setup Initial Entities", + "Delete Initial Entities" + ], + "teardown": "Delete Initial Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "024_02_01 Retrieve Detailed Representation Of Available Entity Type", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/DISC/024_02_01", + "doc": "Check that you can retrieve a detailed representation of a specified NGSI-LD entity type", + "tags": [ + "5_7_7", + "ed-type" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing an Entity Type Info and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/types/{type}'\n method set to 'GET'\n Retrieve Entity Type, with type set to 'Building', with Header['Link'] containing 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'", + "http_verb": "GET", + "endpoint": "types/{type}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation", + "robotfile": "024_02" +} \ No newline at end of file diff --git a/doc/files/027_01.json b/doc/files/027_01.json new file mode 100644 index 00000000..28ab0771 --- /dev/null +++ b/doc/files/027_01.json @@ -0,0 +1,35 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/DISC/027_01", + "test_objective": "Check that you cannot retrieve a detailed representation of an unknown NGSI-LD attribute", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.10", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_10", + "keywords": [ + "Setup Initial Entities", + "Delete Initial Entities" + ], + "teardown": "Delete Initial Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "027_01_01 Retrieve Detailed Representation Of Available Attribute Without Context", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/DISC/027_01_01", + "doc": "Check that you cannot retrieve a detailed representation of an unknown NGSI-LD attribute", + "tags": [ + "5_7_10", + "ed-attr" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing the type 'https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound' and\n Response body containing 'title' element and\n Response Status Code set to 404\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/attributes/{attribute_name}'\n method set to 'GET'\n Retrieve Attribute with attributeName set to 'airQualityLevel'", + "http_verb": "GET", + "endpoint": "attributes/{attribute_name}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation", + "robotfile": "027_01" +} \ No newline at end of file diff --git a/doc/files/027_02.json b/doc/files/027_02.json new file mode 100644 index 00000000..9ba848b4 --- /dev/null +++ b/doc/files/027_02.json @@ -0,0 +1,35 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/DISC/027_02", + "test_objective": "Check that you can retrieve a list with a detailed representation of NGSI-LD attributes", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.10", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_10", + "keywords": [ + "Setup Initial Entities", + "Delete Initial Entities" + ], + "teardown": "Delete Initial Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "027_02_01 Retrieve Detailed Representation Of Available Attribute", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/DISC/027_02_01", + "doc": "Check that you can retrieve a list with a detailed representation of NGSI-LD attributes", + "tags": [ + "5_7_10", + "ed-attr" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing an array of Attributes and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/attributes/{attribute_name}'\n method set to 'GET'\n Retrieve Attribute with attributeName set to 'airQualityLevel'", + "http_verb": "GET", + "endpoint": "attributes/{attribute_name}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation", + "robotfile": "027_02" +} \ No newline at end of file diff --git a/doc/files/043_01.json b/doc/files/CommonBehaviours/043_01.json similarity index 100% rename from doc/files/043_01.json rename to doc/files/CommonBehaviours/043_01.json diff --git a/doc/files/044_01.json b/doc/files/CommonBehaviours/044_01.json similarity index 100% rename from doc/files/044_01.json rename to doc/files/CommonBehaviours/044_01.json diff --git a/doc/files/044_02.json b/doc/files/CommonBehaviours/044_02.json similarity index 100% rename from doc/files/044_02.json rename to doc/files/CommonBehaviours/044_02.json diff --git a/doc/files/044_03.json b/doc/files/CommonBehaviours/044_03.json similarity index 100% rename from doc/files/044_03.json rename to doc/files/CommonBehaviours/044_03.json diff --git a/doc/files/044_04.json b/doc/files/CommonBehaviours/044_04.json similarity index 100% rename from doc/files/044_04.json rename to doc/files/CommonBehaviours/044_04.json diff --git a/doc/files/044_05.json b/doc/files/CommonBehaviours/044_05.json similarity index 100% rename from doc/files/044_05.json rename to doc/files/CommonBehaviours/044_05.json diff --git a/doc/tests/test_CommonBehaviours.py b/doc/tests/test_CommonBehaviours.py index 88806aa4..13f714f0 100644 --- a/doc/tests/test_CommonBehaviours.py +++ b/doc/tests/test_CommonBehaviours.py @@ -43,42 +43,42 @@ class TestCommonBehaviours(TestCase): def test_043_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/043.robot' - expected_value = f'{self.folder_test_suites}/doc/files/043_01.json' + expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/043_01.json' difference_file = f'{self.folder_test_suites}/doc/results/out_043_01.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_044_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_01.robot' - expected_value = f'{self.folder_test_suites}/doc/files/044_01.json' + expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_01.json' difference_file = f'{self.folder_test_suites}/doc/results/out_044_01.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_044_02(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_02.robot' - expected_value = f'{self.folder_test_suites}/doc/files/044_02.json' + expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_02.json' difference_file = f'{self.folder_test_suites}/doc/results/out_044_02.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_044_03(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_03.robot' - expected_value = f'{self.folder_test_suites}/doc/files/044_03.json' + expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_03.json' difference_file = f'{self.folder_test_suites}/doc/results/out_044_03.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_044_04(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_04.robot' - expected_value = f'{self.folder_test_suites}/doc/files/044_04.json' + expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_04.json' difference_file = f'{self.folder_test_suites}/doc/results/out_044_04.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_044_05(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_05.robot' - expected_value = f'{self.folder_test_suites}/doc/files/044_05.json' + expected_value = f'{self.folder_test_suites}/doc/files/CommonBehaviours/044_05.json' difference_file = f'{self.folder_test_suites}/doc/results/out_044_05.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) diff --git a/doc/tests/test_ContextInformation_Consumption.py b/doc/tests/test_ContextInformation_Consumption.py new file mode 100644 index 00000000..4c3d9e8f --- /dev/null +++ b/doc/tests/test_ContextInformation_Consumption.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +from unittest import TestCase +from doc.analysis.generaterobotdata import GenerateRobotData +from json import load, dump +from deepdiff import DeepDiff +from os.path import dirname, exists +from os import listdir, remove, makedirs + + +class TestCIConsumptions(TestCase): + @classmethod + def setUpClass(cls): + TestCIConsumptions.folder_test_suites = dirname(dirname(dirname(__file__))) + folder_results = f'{TestCIConsumptions.folder_test_suites}/doc/results' + + # Check that the folder '/results' exists and if not, create it + if not exists(folder_results): + makedirs(folder_results) + else: + # Delete the /results folder + [remove(f'{folder_results}/{x}') for x in listdir(folder_results) if x.startswith('out')] + + def setUp(self) -> None: + self.folder_test_suites = dirname(dirname(dirname(__file__))) + + def common_function(self, robot_file, expected_value, difference_file): + data = GenerateRobotData(robot_file=robot_file, + execdir=self.folder_test_suites) + data.parse_robot() + obtained_response = data.get_info() + + with open(expected_value, 'r') as file: + expected_response = load(file) + + result = DeepDiff(t1=obtained_response, t2=expected_response, ignore_order=True) + + if len(result) != 0: + # There are some differences + with open(difference_file, 'w') as fp: + dump(obj=obtained_response, indent=2, fp=fp) + + assert False, f'They are some difference between the expected and obtained dictionaries: \n {result}' + + def test_027_01(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01.robot' + expected_value = f'{self.folder_test_suites}/doc/files/027_01.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_027_01.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_027_02(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_02.robot' + expected_value = f'{self.folder_test_suites}/doc/files/027_02.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_027_02.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_024_01(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01.robot' + expected_value = f'{self.folder_test_suites}/doc/files/024_01.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_024_01.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_024_02(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_02.robot' + expected_value = f'{self.folder_test_suites}/doc/files/024_02.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_024_02.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) -- GitLab From 5628f4eaa8513a196d102f42b282b6d1570ddbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Thu, 28 Sep 2023 21:36:55 +0200 Subject: [PATCH 6/9] Added 019_01_01 --- .../Entity/QueryEntities/019_01_01.robot | 4 +-- .../Entity/QueryEntities/019_01_02.robot | 2 +- doc/analysis/checks.py | 2 +- doc/analysis/generaterobotdata.py | 1 + doc/analysis/parserobotfile.py | 31 ++++++++--------- doc/analysis/parsevariablesfile.py | 2 +- doc/analysis/requests.py | 20 +++++++++-- doc/files/019_01_01.json | 34 +++++++++++++++++++ .../test_ContextInformation_Consumption.py | 7 ++++ 9 files changed, 78 insertions(+), 25 deletions(-) create mode 100644 doc/files/019_01_01.json diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_01.robot index 6e4586ae..7f99c790 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_01.robot @@ -17,7 +17,7 @@ ${entity_type}= https://ngsi-ld-test-suite/context#Building *** Test Cases *** -Query several entities based on ids +019_01_01 Query several entities based on ids [Documentation] Check that you can query several entities based on ids [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -48,7 +48,7 @@ Query several entities based on ids ... entity_ids=${entities_ids_to_be_retrieved} ... entity_types=${entity_types_to_be_retrieved} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_02.robot index e2c6e344..f7c95ec2 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_02.robot @@ -23,7 +23,7 @@ ${parking_entity_type}= https://ngsi-ld-test-suite/context#OffStreetParking *** Test Cases *** -Query several entities based on the entities types +019_01_02 Query several entities based on the entities types [Documentation] Check that you can query several entities based on the entities types [Tags] e-query 5_7_2 ${building_entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/doc/analysis/checks.py b/doc/analysis/checks.py index 987f0202..17d68a16 100644 --- a/doc/analysis/checks.py +++ b/doc/analysis/checks.py @@ -212,7 +212,7 @@ class Checks: @staticmethod def check_response_body_containing_list_containing_entity_elements(kwargs: list) -> str: - return 'Response Body containing a list containing Entity elements, containing ${value} provided' + return 'Response Body containing a list containing Entity Elements, containing ${value} provided' @staticmethod def check_response_body_containing_list_containing_entity_elements_with_different_types(kwargs: list) -> str: diff --git a/doc/analysis/generaterobotdata.py b/doc/analysis/generaterobotdata.py index 384e15a4..cfd37157 100644 --- a/doc/analysis/generaterobotdata.py +++ b/doc/analysis/generaterobotdata.py @@ -31,6 +31,7 @@ class GenerateRobotData: 'Discovery/RetrieveAvailableEntityTypeInformation': 'DISC', 'Entity/RetrieveEntity': 'E', 'Entities/CreateEntity': 'E', + 'Entity/QueryEntities': 'E', 'Provision': 'Prov' } self.references = { diff --git a/doc/analysis/parserobotfile.py b/doc/analysis/parserobotfile.py index 2f269074..7c64103c 100644 --- a/doc/analysis/parserobotfile.py +++ b/doc/analysis/parserobotfile.py @@ -39,19 +39,6 @@ class ParseRobotFile: else: raise Exception("Error, the variable is not following the format ${thing} = ") - # def get_expected_status_code(self, keyword: str): - # # Check Response Status Code ${expected_status_code} ${response.status_code} - # # Check Response Body Containing ProblemDetails Element Containing Type Element set to - # # ... ${response.json()} - # # ... ${ERROR_TYPE_LD_CONTEXT_NOT_AVAILABLE} - # string = self.get_substring(initial_string=keyword, final_string='\n', include=True) - # expected_status_code = string.split(' ')[1] - # - # if expected_status_code.isdigit(): - # return expected_status_code - # else: - # return self.variables[expected_status_code] - def get_apiutils_path(self): string = self.get_substring(initial_string='Resource', final_string='*** Variables ***', include=True) result = [item for item in string.split('\n') if 'ApiUtils.resource' in item and item[0] != '#'] @@ -92,10 +79,20 @@ class ParseRobotFile: indexes = list() self.test_case_names = list() - for match in matches: - name = match.strip() - self.test_case_names.append(name) - indexes.append(string.find(name)) + if matches: + for match in matches: + name = match.strip() + self.test_case_names.append(name) + indexes.append(string.find(name)) + else: + # The test case has the same id. number as the test suite + pattern = f'{self.test_suite}\s.*' + matches = re.findall(pattern=pattern, string=string) + + for match in matches: + name = match.strip() + self.test_case_names.append(name) + indexes.append(string.find(name)) self.test_cases = dict() for i in range(0, len(indexes)-1): diff --git a/doc/analysis/parsevariablesfile.py b/doc/analysis/parsevariablesfile.py index 26838f54..f56bd51c 100644 --- a/doc/analysis/parsevariablesfile.py +++ b/doc/analysis/parsevariablesfile.py @@ -12,7 +12,7 @@ class ParseVariablesFile: file_content = file.read() file_content = file_content.split('\n') - file_content = [x.split('=') for x in file_content if x is not ''] + file_content = [x.split('=') for x in file_content if x != ''] self.variables = {x[0].strip(): x[1].replace("'", "").strip() for x in file_content} diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index 05d2012d..9c4cf5ab 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -64,8 +64,13 @@ class Requests: 'Retrieve Entity Type': { 'positions': [0, 1], 'params': ['type', 'context'] + }, + 'Query Entities': { + 'positions': [0, 1], + 'params': ['entity_ids', 'entity_types'] } } + self.description = { 'Create Entity Selecting Content Type': Requests.create_entity_selecting_content_type, @@ -96,9 +101,10 @@ class Requests: 'Retrieve Attribute': Requests.retrieve_attribute, 'Retrieve Entity Type': - Requests.retrieve_entity_type - } - + Requests.retrieve_entity_type, + 'Query Entities': + Requests.query_entities + } self.variables = variables self.apiutils_variables = apiutils_variables @@ -333,6 +339,14 @@ class Requests: return result + @staticmethod + def query_entities(kwargs) -> str: + if 'entity_ids' in kwargs and 'entity_types' in kwargs: + return (f"Request Query Entities with entity_ids set to '{kwargs['entity_ids']}' " + f"and entity_types set to '{kwargs['entity_types']}") + else: + raise Exception(f"ERROR, expected entity_ids and entity_types attributes but received '{kwargs}'") + def get_value(self, params, param_position, param_key): data = [x for x in params if f'{param_key}=' in x] diff --git a/doc/files/019_01_01.json b/doc/files/019_01_01.json new file mode 100644 index 00000000..67dee5a5 --- /dev/null +++ b/doc/files/019_01_01.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_01", + "test_objective": "Check that you can query several entities based on ids", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_2", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_01_01 Query several entities based on ids", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_01", + "doc": "Check that you can query several entities based on ids", + "tags": [ + "5_7_2", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing a list containing Entity Elements, containing ${value} provided and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to '${entities_ids_to_be_retrieved}' and entity_types set to '${entity_types_to_be_retrieved}", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_01_01" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Consumption.py b/doc/tests/test_ContextInformation_Consumption.py index 4c3d9e8f..ad2812bb 100644 --- a/doc/tests/test_ContextInformation_Consumption.py +++ b/doc/tests/test_ContextInformation_Consumption.py @@ -68,3 +68,10 @@ class TestCIConsumptions(TestCase): difference_file = f'{self.folder_test_suites}/doc/results/out_024_02.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_019_01_01(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_01.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_01_01.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_01.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) -- GitLab From 051e0a92c1e6b0ca49e32779cce29143c50ba539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Fri, 29 Sep 2023 08:51:03 +0200 Subject: [PATCH 7/9] Working with ContextInformation/Consumptions test suites --- .../Entity/QueryEntities/019_01_03.robot | 4 +- .../Entity/QueryEntities/019_01_04.robot | 6 +- .../Entity/QueryEntities/019_01_05.robot | 4 +- .../Entity/QueryEntities/019_02_01.robot | 4 +- .../Entity/QueryEntities/019_02_02.robot | 4 +- .../Entity/QueryEntities/019_02_03.robot | 4 +- .../Entity/QueryEntities/019_02_04.robot | 4 +- .../Entity/QueryEntities/019_02_05.robot | 8 +- .../Entity/QueryEntities/019_03_01.robot | 2 +- .../Entity/QueryEntities/019_03_02.robot | 2 +- .../Entity/QueryEntities/019_03_03.robot | 2 +- .../Entity/QueryEntities/019_03_04.robot | 2 +- .../Entity/QueryEntities/019_03_05.robot | 6 +- .../Entity/QueryEntities/019_04.robot | 4 +- .../Entity/QueryEntities/019_05.robot | 4 +- .../Entity/QueryEntities/019_06.robot | 2 +- .../Entity/RetrieveEntity/018_01_01.robot | 2 +- .../Entity/RetrieveEntity/018_01_02.robot | 2 +- .../Entity/RetrieveEntity/018_01_03.robot | 2 +- .../Entity/RetrieveEntity/018_02.robot | 4 +- .../Entity/RetrieveEntity/018_03_01.robot | 2 +- .../Entity/RetrieveEntity/018_03_02.robot | 2 +- .../Entity/RetrieveEntity/018_04.robot | 2 +- .../Entity/RetrieveEntity/018_05.robot | 2 +- .../Entity/RetrieveEntity/018_06.robot | 4 +- doc/analysis/requests.py | 18 ++- doc/files/019_01_01.json | 2 +- doc/files/019_01_03.json | 34 +++++ doc/files/019_01_04.json | 34 +++++ doc/files/019_02_01.json | 34 +++++ doc/files/019_02_03.json | 34 +++++ doc/files/019_03_01.json | 34 +++++ doc/files/019_03_02.json | 34 +++++ doc/files/019_03_03.json | 34 +++++ doc/files/019_04.json | 34 +++++ doc/files/019_05.json | 34 +++++ .../test_ContextInformation_Consumption.py | 129 ++++++++++++++++++ 37 files changed, 490 insertions(+), 49 deletions(-) create mode 100644 doc/files/019_01_03.json create mode 100644 doc/files/019_01_04.json create mode 100644 doc/files/019_02_01.json create mode 100644 doc/files/019_02_03.json create mode 100644 doc/files/019_03_01.json create mode 100644 doc/files/019_03_02.json create mode 100644 doc/files/019_03_03.json create mode 100644 doc/files/019_04.json create mode 100644 doc/files/019_05.json diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_03.robot index 982470b9..6c4dfaff 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_03.robot @@ -18,7 +18,7 @@ ${entity_id_pattern}= urn:ngsi-ld:Building:.* *** Test Cases *** -Query several entities based on the given id pattern +019_01_03 Query several entities based on the given id pattern [Documentation] Check that you can query several entities based on the given id pattern [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -41,7 +41,7 @@ Query several entities based on the given id pattern ... entity_id_pattern=${entity_id_pattern} ... entity_types=${entity_types_to_be_retrieved} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_04.robot index 636d6416..4f049e05 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_04.robot @@ -20,7 +20,7 @@ ${attribute_subcategory}= https://ngsi-ld-test-suite/context#subCatego *** Test Cases *** -Query several entities based on attribute names +019_01_04 Query several entities based on attribute names [Documentation] Check that you can query several entities based on attribute names [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -44,13 +44,13 @@ Query several entities based on attribute names @{entities_ids_to_be_compared}= Create List ${first_entity_id} ${response}= Query Entities attrs=${attributes_to_be_retrieved} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_05.robot index 8ff94d0f..612d7c81 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_05.robot @@ -18,7 +18,7 @@ ${geometry_property}= location *** Test Cases *** -Query several entities based on a list of properties +019_01_05 Query several entities based on a list of properties [Documentation] Check that you can query entitites based on a list of properties [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -43,7 +43,7 @@ Query several entities based on a list of properties ... geoproperty=${geometry_property} ... accept=${CONTENT_TYPE_LD_JSON} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot index 88d825e1..9d3ea8fa 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot @@ -17,7 +17,7 @@ ${entity_type}= https://ngsi-ld-test-suite/context#Building *** Test Cases *** -Query several entities via POST Interaction based on ids +019_02_01 Query several entities via POST Interaction based on ids [Documentation] Check that you can query several entities via POST Interaction based on ids [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -53,7 +53,7 @@ Query several entities via POST Interaction based on ids ... entity_ids=${entities_ids_to_be_retrieved} ... entity_types=${entity_types_to_be_retrieved} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_02.robot index 4f129cb3..719f9c7f 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_02.robot @@ -23,7 +23,7 @@ ${parking_entity_type}= https://ngsi-ld-test-suite/context#OffStreetParking *** Test Cases *** -Query several entities via POST Interaction based on the entities types +019_02_02 Query several entities via POST Interaction based on the entities types [Documentation] Check that you can query several entities via POST Interaction based on the entities types [Tags] e-query 5_7_2 ${building_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -51,7 +51,7 @@ Query several entities via POST Interaction based on the entities types ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, ${vehicle_entity_type} ${parking_entity_type} ${response}= Query Entities entity_types=${entity_types_to_be_retrieved} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entity_types_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot index 5f5d50b7..501cf462 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot @@ -18,7 +18,7 @@ ${entity_id_pattern}= urn:ngsi-ld:Building:.* *** Test Cases *** -Query several entities via POST Interaction based on the given id pattern +019_02_03 Query several entities via POST Interaction based on the given id pattern [Documentation] Check that you can query several entities via POST Interaction based on the given id pattern [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -41,7 +41,7 @@ Query several entities via POST Interaction based on the given id pattern ... entity_id_pattern=${entity_id_pattern} ... entity_types=${entity_types_to_be_retrieved} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_04.robot index 0e204199..5e621262 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_04.robot @@ -18,7 +18,7 @@ ${attribute_subcategory}= https://ngsi-ld-test-suite/context#subCatego *** Test Cases *** -Query several entities via POST Interaction based on attribute names +019_02_04 Query several entities via POST Interaction based on attribute names [Documentation] Check that you can query several entities via POST Interaction based on attribute names [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -42,7 +42,7 @@ Query several entities via POST Interaction based on attribute names @{entities_ids_to_be_retrieved}= Create List ${first_entity_id} ${second_entity_id} ${response}= Query Entities attrs=${attributes_to_be_retrieved} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_retrieved} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot index 1efb21bb..717c4787 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_05.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check that you can query entitites via POST Interaction based on a list of properties +Documentation Check that you can query entities via POST Interaction based on a list of properties Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption/ApiUtils.resource # Resource ${EXECDIR}/resources/ApiUtils.resource @@ -18,8 +18,8 @@ ${geometry_property}= location *** Test Cases *** -Query several entities via POST Interaction based on a list of properties - [Documentation] Check that you can query entitites via POST Interaction based on a list of properties +019_02_05 Query several entities via POST Interaction based on a list of properties + [Documentation] Check that you can query entities via POST Interaction based on a list of properties [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} Set Suite Variable ${first_entity_id} @@ -41,7 +41,7 @@ Query several entities via POST Interaction based on a list of properties ... entity_types=${entity_types_to_be_retrieved} ... geoproperty=${geometry_property} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_01.robot index b912976e..95f6cd63 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_01.robot @@ -18,7 +18,7 @@ ${entity_invalid_id_two}= thisisaninvaliduri2 *** Test Cases *** -Query entities based on incorrect ids +019_03_01 Query entities based on incorrect ids [Documentation] Check that you cannot query entities if the requested ids are incorrect [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_02.robot index cfd1b652..58a859e0 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_02.robot @@ -19,7 +19,7 @@ ${invalid_entity_type_two}= invalid_entity_type_two *** Test Cases *** -Query entities based on incorrect entity types +019_03_02 Query entities based on incorrect entity types [Documentation] Check that you cannot query entities if the requested entity types are incorrect [Tags] e-query 5_7_2 ${building_entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_03.robot index f091a50b..89300600 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_03.robot @@ -17,7 +17,7 @@ ${invalid_entity_id_pattern}= invalid_entity_id_pattern** *** Test Cases *** -Query several entities based on incorrect id pattern +019_03_03 Query several entities based on incorrect id pattern [Documentation] Check that you cannot query entities if the requested id pattern is incorrect [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_04.robot index f329c08a..8e6ab34b 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_04.robot @@ -18,7 +18,7 @@ ${invalid_attribute_two}= type *** Test Cases *** -Query several entities based on incorrect attribute names +019_03_04 Query several entities based on incorrect attribute names [Documentation] Check that you cannot query entities if the requested attribute names are incorrect [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_05.robot index 998771c7..b9d48478 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_05.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check that you cannot query entitites if the request has a wrong geometryProperty +Documentation Check that you cannot query entities if the request has a wrong geometryProperty Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption/ApiUtils.resource # Resource ${EXECDIR}/resources/ApiUtils.resource @@ -20,8 +20,8 @@ ${geoproperty}= location *** Test Cases *** -Query entitites when the request has a wrong geometryProperty - [Documentation] Check that you cannot query entitites if the request has a wrong geometryProperty +019_03_05 Query entities when the request has a wrong geometryProperty + [Documentation] Check that you cannot query entities if the request has a wrong geometryProperty [Tags] e-query 5_7_2 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} Set Suite Variable ${first_entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_04.robot index 2895591a..c6204e70 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_04.robot @@ -18,7 +18,7 @@ ${entity_type}= https://ngsi-ld-test-suite/context#Building *** Test Cases *** -Query entities in a simplified representation +019_04_01 Query entities in a simplified representation [Documentation] Check that the queried entities by Id can be returned in a simplified representation [Tags] e-query 6_3_7 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -50,7 +50,7 @@ Query entities in a simplified representation ... entity_types=${entity_types_to_be_retrieved} ... options=${options_parameter} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot index 7e9a8ac6..37fdd035 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot @@ -18,7 +18,7 @@ ${accept_header}= application/geo+json *** Test Cases *** -Get an entity by id that can be returned in a geoJSON format +019_05_01 Get an entity by id that can be returned in a geoJSON format [Documentation] Check that the queried entities by id can be returned in a geoJSON format [Tags] e-query 6_3_7 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} @@ -50,7 +50,7 @@ Get an entity by id that can be returned in a geoJSON format ... entity_types=${entity_types_to_be_retrieved} ... accept=${accept_header} Check Response Status Code 200 ${response.status_code} - Check Response Body Containing List Containing Entity elements + Check Response Body Containing List Containing Entity Elements ... ${expectation_filename} ... ${entities_ids_to_be_compared} ... ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_06.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_06.robot index 6aae3100..5a472f4c 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_06.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_06.robot @@ -17,7 +17,7 @@ ${limit}= 2 *** Test Cases *** -Query entities specifying a maximum number of results +019_06_01 Query entities specifying a maximum number of results [Documentation] Check that you can query entities specifying a maximum number of results [Tags] e-query 6_3_10 ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_01.robot index f2596be6..3a71217d 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_01.robot @@ -16,7 +16,7 @@ ${expectation_filename}= building-simple-attributes-expectation.jsonld *** Test Cases *** -018_01_01_Get an entity by id +018_01_01 Get an entity by id [Documentation] Check that you can get an entity by id [Tags] e-retrieve 5_7_1 ${entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_02.robot index 93fe8fa9..9644d32e 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_02.robot @@ -18,7 +18,7 @@ ${attribute_subcategory}= https://ngsi-ld-test-suite/context#subCatego *** Test Cases *** -018_01_02_Query some attributes from an entity +018_01_02 Query some attributes from an entity [Documentation] Check that you can query some attributes from an entity [Tags] e-retrieve 5_7_1 ${entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_03.robot index 18e91571..49bc76a4 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_03.robot @@ -17,7 +17,7 @@ ${geometry_property}= location *** Test Cases *** -018_01_03_Query the geometry property from an entity +018_01_03 Query the geometry property from an entity [Documentation] Check that you can query the geometry property from an entity [Tags] e-retrieve 5_7_1 ${entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_02.robot index a5a655c6..6500df58 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_02.robot @@ -9,9 +9,9 @@ Test Template Get Entity With Invalid/Missing Id *** Test Cases *** ENTITY_ID EXPECTED_STATUS_CODE PROBLEM_TYPE -018_02_01_Get an entity if the Entity Id is not present +018_02_01 Get an entity if the Entity Id is not present ${EMPTY} 400 ${ERROR_TYPE_BAD_REQUEST_DATA} -018_02_02_Get an entity if the Entity Id is not a valid URI +018_02_02 Get an entity if the Entity Id is not a valid URI thisisaninvaliduri 400 ${ERROR_TYPE_BAD_REQUEST_DATA} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_03_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_03_01.robot index c06471a1..2ce7aa0d 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_03_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_03_01.robot @@ -12,7 +12,7 @@ ${building_id_prefix}= urn:ngsi-ld:Building: *** Test Cases *** -Get an entity if the Entity Id is not known to the system +018_03_01 Get an entity if the Entity Id is not known to the system [Documentation] Check that you cannot get an entity if the entity id or attributes are not known to the system [Tags] e-retrieve 5_7_1 ${entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_03_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_03_02.robot index 1d1784ae..598b79ed 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_03_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_03_02.robot @@ -16,7 +16,7 @@ ${attribute_not_known}= property_not_found *** Test Cases *** -Get an entity if an attribute is not known to the system +018_03_02 Get an entity if an attribute is not known to the system [Documentation] Check that you cannot get an entity if an attribute is not known to the system [Tags] e-retrieve 5_7_1 ${entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_04.robot index 8692a820..810eef74 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_04.robot @@ -17,7 +17,7 @@ ${options_parameter}= keyValues *** Test Cases *** -Get an entity in a simplified representation +018_04_01 Get an entity in a simplified representation [Documentation] Check that the queried entity by Id can be returned in a simplified representation [Tags] e-retrieve 6_3_7 ${entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_05.robot index 406eebf2..8a995df0 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_05.robot @@ -18,7 +18,7 @@ ${accept_header}= application/geo+json *** Test Cases *** -Get an entity by id that can be returned in a geoJSON format +018_05_01 Get an entity by id that can be returned in a geoJSON format [Documentation] Check that the queried entity by id can be returned in a geoJSON format [Tags] e-retrieve 6_3_7 ${entity_id}= Generate Random Entity Id ${building_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_06.robot b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_06.robot index acacf50d..b1589499 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_06.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_06.robot @@ -19,10 +19,10 @@ ${creation_jsonld_expectation_filename}= building-simple-attributes-sample-co *** Test Cases *** CONTEXT EXPECTED_PAYLOAD -EmptyJsonLdContext +018_06_01 EmptyJsonLdContext [Tags] e-retrieve 6_3_5 ${EMPTY} ${empty_jsonld_expectation_filename} -CreationTimeJsonLdContext +018_06_02 CreationTimeJsonLdContext [Tags] e-retrieve 6_3_5 ${ngsild_test_suite_context} ${creation_jsonld_expectation_filename} diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index 9c4cf5ab..9bfba3e5 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -67,7 +67,7 @@ class Requests: }, 'Query Entities': { 'positions': [0, 1], - 'params': ['entity_ids', 'entity_types'] + 'params': ['entity_ids', 'entity_types', 'accepts'] } } @@ -341,11 +341,17 @@ class Requests: @staticmethod def query_entities(kwargs) -> str: - if 'entity_ids' in kwargs and 'entity_types' in kwargs: - return (f"Request Query Entities with entity_ids set to '{kwargs['entity_ids']}' " - f"and entity_types set to '{kwargs['entity_types']}") - else: - raise Exception(f"ERROR, expected entity_ids and entity_types attributes but received '{kwargs}'") + result = "Request Query Entities" + if 'entity_ids' in kwargs and kwargs['entity_ids'] != '': + result = f"{result} with entity_ids set to '{kwargs['entity_ids']}'" + + if 'entity_types' in kwargs and kwargs['entity_types'] != '': + result = f"{result} with entity_types set to '{kwargs['entity_types']}" + + if 'accept' in kwargs and kwargs['accept'] != '': + result = f"{result} with Header['Accept'] set to '{kwargs['accept']}'" + + return result def get_value(self, params, param_position, param_key): data = [x for x in params if f'{param_key}=' in x] diff --git a/doc/files/019_01_01.json b/doc/files/019_01_01.json index 67dee5a5..0d09061c 100644 --- a/doc/files/019_01_01.json +++ b/doc/files/019_01_01.json @@ -23,7 +23,7 @@ "teardown": null, "template": null, "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing a list containing Entity Elements, containing ${value} provided and\n Response Status Code set to 200\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to '${entities_ids_to_be_retrieved}' and entity_types set to '${entity_types_to_be_retrieved}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to '${entities_ids_to_be_retrieved}' with entity_types set to '${entity_types_to_be_retrieved}", "http_verb": "GET", "endpoint": "entities/" } diff --git a/doc/files/019_01_03.json b/doc/files/019_01_03.json new file mode 100644 index 00000000..57c24c27 --- /dev/null +++ b/doc/files/019_01_03.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_03", + "test_objective": "Check that you can query several entities based on the given id pattern", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_2", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_01_03 Query several entities based on the given id pattern", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_03", + "doc": "Check that you can query several entities based on the given id pattern", + "tags": [ + "5_7_2", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing a list containing Entity Elements, containing ${value} provided and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to 'entity_id_pattern=${entity_id_pattern}' with entity_types set to '${entity_types_to_be_retrieved}", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_01_03" +} \ No newline at end of file diff --git a/doc/files/019_01_04.json b/doc/files/019_01_04.json new file mode 100644 index 00000000..8b442220 --- /dev/null +++ b/doc/files/019_01_04.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_04", + "test_objective": "Check that you can query several entities based on attribute names", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_2", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_01_04 Query several entities based on attribute names", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_04", + "doc": "Check that you can query several entities based on attribute names", + "tags": [ + "5_7_2", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing a list containing Entity Elements, containing ${value} provided and\n Response Body containing a list containing Entity Elements, containing ${value} provided and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to 'attrs=${attributes_to_be_retrieved}'", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_01_04" +} \ No newline at end of file diff --git a/doc/files/019_02_01.json b/doc/files/019_02_01.json new file mode 100644 index 00000000..13a78d72 --- /dev/null +++ b/doc/files/019_02_01.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_02_01", + "test_objective": "Check that you can query several entities via POST Interaction based on ids", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_2", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_02_01 Query several entities via POST Interaction based on ids", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_02_01", + "doc": "Check that you can query several entities via POST Interaction based on ids", + "tags": [ + "5_7_2", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing a list containing Entity Elements, containing ${value} provided and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to '${entities_ids_to_be_retrieved}' with entity_types set to '${entity_types_to_be_retrieved}", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_02_01" +} \ No newline at end of file diff --git a/doc/files/019_02_03.json b/doc/files/019_02_03.json new file mode 100644 index 00000000..8307d4aa --- /dev/null +++ b/doc/files/019_02_03.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_02_03", + "test_objective": "Check that you can query several entities via POST Interaction based on the given id pattern", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_2", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_02_03 Query several entities via POST Interaction based on the given id pattern", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_02_03", + "doc": "Check that you can query several entities via POST Interaction based on the given id pattern", + "tags": [ + "5_7_2", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing a list containing Entity Elements, containing ${value} provided and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to 'entity_id_pattern=${entity_id_pattern}' with entity_types set to '${entity_types_to_be_retrieved}", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_02_03" +} \ No newline at end of file diff --git a/doc/files/019_03_01.json b/doc/files/019_03_01.json new file mode 100644 index 00000000..ecac878a --- /dev/null +++ b/doc/files/019_03_01.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_01", + "test_objective": "Check that you cannot query entities if the requested ids are incorrect", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_2", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_03_01 Query entities based on incorrect ids", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_01", + "doc": "Check that you cannot query entities if the requested ids are incorrect", + "tags": [ + "5_7_2", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing the type 'https://uri.etsi.org/ngsi-ld/errors/BadRequestData' and\n Response body containing 'title' element and\n Response Status Code set to 400\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to '${entities_ids_to_be_retrieved}' with entity_types set to '${entity_types_to_be_retrieved}", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_03_01" +} \ No newline at end of file diff --git a/doc/files/019_03_02.json b/doc/files/019_03_02.json new file mode 100644 index 00000000..fad12f0e --- /dev/null +++ b/doc/files/019_03_02.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_02", + "test_objective": "Check that you cannot query entities if the requested entity types are incorrect", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_2", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_03_02 Query entities based on incorrect entity types", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_02", + "doc": "Check that you cannot query entities if the requested entity types are incorrect", + "tags": [ + "5_7_2", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing the type 'https://uri.etsi.org/ngsi-ld/errors/BadRequestData' and\n Response body containing 'title' element and\n Response Status Code set to 400\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to 'entity_types=${entity_types_to_be_retrieved}' with entity_types set to '${entity_types_to_be_retrieved}", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_03_02" +} \ No newline at end of file diff --git a/doc/files/019_03_03.json b/doc/files/019_03_03.json new file mode 100644 index 00000000..0875c05c --- /dev/null +++ b/doc/files/019_03_03.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_03", + "test_objective": "Check that you cannot query entities if the requested id pattern is incorrect", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_2", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_03_03 Query several entities based on incorrect id pattern", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_03", + "doc": "Check that you cannot query entities if the requested id pattern is incorrect", + "tags": [ + "5_7_2", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing the type 'https://uri.etsi.org/ngsi-ld/errors/BadRequestData' and\n Response body containing 'title' element and\n Response Status Code set to 400\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to 'entity_id_pattern=${invalid_entity_id_pattern}' with entity_types set to '${entity_types_to_be_retrieved}", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_03_03" +} \ No newline at end of file diff --git a/doc/files/019_04.json b/doc/files/019_04.json new file mode 100644 index 00000000..cf11538d --- /dev/null +++ b/doc/files/019_04.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_04", + "test_objective": "Check that the queried entities by Id can be returned in a simplified representation", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.7", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_6_3_7", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_04_01 Query entities in a simplified representation", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_04_01", + "doc": "Check that the queried entities by Id can be returned in a simplified representation", + "tags": [ + "6_3_7", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing a list containing Entity Elements, containing ${value} provided and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to '${entities_ids_to_be_retrieved}' with entity_types set to '${entity_types_to_be_retrieved}", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_04" +} \ No newline at end of file diff --git a/doc/files/019_05.json b/doc/files/019_05.json new file mode 100644 index 00000000..c2da3830 --- /dev/null +++ b/doc/files/019_05.json @@ -0,0 +1,34 @@ +{ + "tp_id": "TP/NGSI-LD/CI/CONS/E/019_05", + "test_objective": "Check that the queried entities by id can be returned in a geoJSON format", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.7", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_6_3_7", + "keywords": [ + "Delete Entities" + ], + "teardown": "Delete Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "019_05_01 Get an entity by id that can be returned in a geoJSON format", + "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_05_01", + "doc": "Check that the queried entities by id can be returned in a geoJSON format", + "tags": [ + "6_3_7", + "e-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Response Body containing a list containing Entity Elements, containing ${value} provided and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/'\n method set to 'GET'\n Request Query Entities with entity_ids set to '${entities_ids_to_be_retrieved}' with entity_types set to '${entity_types_to_be_retrieved}", + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/Entity/QueryEntities", + "robotfile": "019_05" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Consumption.py b/doc/tests/test_ContextInformation_Consumption.py index ad2812bb..a8f18e19 100644 --- a/doc/tests/test_ContextInformation_Consumption.py +++ b/doc/tests/test_ContextInformation_Consumption.py @@ -10,6 +10,7 @@ from os import listdir, remove, makedirs class TestCIConsumptions(TestCase): @classmethod def setUpClass(cls): + # TODO: Test Suites checked until 019_01_01 TestCIConsumptions.folder_test_suites = dirname(dirname(dirname(__file__))) folder_results = f'{TestCIConsumptions.folder_test_suites}/doc/results' @@ -55,6 +56,18 @@ class TestCIConsumptions(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_025_01(self): + self.fail("(025_01) Test Suite with Test Template, not yet implemented") + + def test_022_01(self): + self.fail("(022_01) Test Suite with Test Template, not yet implemented") + + def test_026_01(self): + self.fail("(026_01) Test Suite with Test Template, not yet implemented") + + def test_023_01(self): + self.fail("(023_01) Test Suite with Test Template, not yet implemented") + def test_024_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/024_01.json' @@ -75,3 +88,119 @@ class TestCIConsumptions(TestCase): difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_01.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_019_01_02(self): + self.fail("(019_01_02) Problems with Request parameters") + + def test_019_01_03(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_03.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_01_03.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_03.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_019_01_04(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_04.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_01_04.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_04.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_019_01_05(self): + self.fail("(019_01_05) Problems with Request parameters") + + def test_019_02_01(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_02_01.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_02_01.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_019_02_02(self): + self.fail("(019_02_02) Problems with Request parameters") + + def test_019_02_03(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_02_03.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_02_03.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_019_02_04(self): + self.fail("(019_02_04) Problems with Request parameters") + + def test_019_02_05(self): + self.fail("(019_02_05) Problems with Request parameters") + + def test_019_03_01(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_01.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_03_01.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_03_01.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_019_03_02(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_02.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_03_02.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_03_02.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_019_03_03(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_03.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_03_03.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_03_03.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_019_03_04(self): + self.fail("(019_03_04) Problems with Request parameters") + + def test_019_03_05(self): + self.fail("(019_03_04) Problems with Request parameters") + + def test_019_04(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_04.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_04.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_04.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + self.fail("(019_04) Problems with Request parameters, Query Entities missing options parameter") + + def test_019_05(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot' + expected_value = f'{self.folder_test_suites}/doc/files/019_05.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_019_05.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + self.fail("(019_04) Problems with Request parameters, Query Entities missing accept parameter") + + def test_019_06(self): + self.fail("(019_06) Problems with 'Check Response Body Containing Number Of Entities'") + + def test_018_01_01(self): + self.fail("(018_01_01) Problems with Query Entity, context-type information used for Link information") + + def test_018_01_02(self): + self.fail("(018_01_02) Problems with Query Entity") + + def test_018_01_03(self): + self.fail("(018_01_03) Problems with Query Entity") + + def test_018_02(self): + self.fail("(018_02) Test Suite with Test Template, not yet implemented") + + def test_018_03_01(self): + self.fail("(018_03_01) Problems with Query Entity") + + def test_018_03_02(self): + self.fail("(018_03_02) Problems with Query Entity") + + def test_018_04(self): + self.fail("(018_04) Problems with Request parameters, Query Entity missing options parameter") + + def test_018_05(self): + self.fail("(018_05) Problems with Request parameters, Query Entity missing options parameter") + + def test_018_06(self): + self.fail("(018_06) Test Suite with Test Template, not yet implemented") -- GitLab From f76cd5526db42651ffb9ff5f056a804f0bbac885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Fri, 29 Sep 2023 12:10:42 +0200 Subject: [PATCH 8/9] Complete the first overview of the ContextInformatin/Comsumption Test Suites --- .../021_01.robot | 4 +- .../021_02.robot | 2 +- .../021_03.robot | 2 +- .../021_04.robot | 2 +- .../021_05.robot | 2 +- .../021_06.robot | 2 +- .../021_07.robot | 2 +- .../021_08.robot | 2 +- .../021_09.robot | 4 +- .../021_10.robot | 2 +- .../021_12.robot | 2 +- .../020_01.robot | 2 +- .../020_02.robot | 2 +- .../020_03.robot | 2 +- .../020_06.robot | 2 +- .../020_07.robot | 2 +- .../020_08.robot | 2 +- .../020_10.robot | 2 +- doc/analysis/checks.py | 16 ++-- doc/analysis/generaterobotdata.py | 5 +- doc/analysis/parserobotfile.py | 1 - doc/analysis/requests.py | 3 + doc/files/019_01_01.json | 4 +- doc/files/019_01_03.json | 4 +- doc/files/019_01_04.json | 4 +- doc/files/019_02_01.json | 4 +- doc/files/019_02_03.json | 4 +- doc/files/019_03_01.json | 4 +- doc/files/019_03_02.json | 4 +- doc/files/019_03_03.json | 4 +- doc/files/019_04.json | 4 +- doc/files/019_05.json | 4 +- doc/files/021_02.json | 35 +++++++++ doc/files/024_01.json | 4 +- doc/files/024_02.json | 4 +- doc/files/027_01.json | 4 +- doc/files/027_02.json | 4 +- .../test_ContextInformation_Consumption.py | 73 +++++++++++++++++++ 38 files changed, 170 insertions(+), 59 deletions(-) create mode 100644 doc/files/021_02.json diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_01.robot index 8e7af978..c71f7929 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_01.robot @@ -19,9 +19,9 @@ ${bus_payload_file}= 2020-08-bus-temporal-representation-sample.j *** Test Cases *** TIMEREL TIMEAT EXPECTATION_FILE -After [Tags] te-query 5_7_4 +021_01_01 After [Tags] te-query 5_7_4 after 2020-08-01T12:04:00Z vehicles-temporal-representation-021-01-01-expectation.jsonld -Before [Tags] te-query 5_7_4 +021_01_02 Before [Tags] te-query 5_7_4 before 2020-09-01T13:06:00Z vehicles-temporal-representation-021-01-02-expectation.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_02.robot index 58cc6a91..baf110a4 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_02.robot @@ -17,7 +17,7 @@ ${expectation_file}= vehicles-temporal-representation-021-02-expe *** Test Cases *** -Query the temporal evolution of certain attributes of entities +021_02_01 Query the temporal evolution of certain attributes of entities [Documentation] Check that you can query the temporal evolution of certain attributes of entities [Tags] te-query 5_7_4 ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Vehicle diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_03.robot index 81629935..d5d247ae 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_03.robot @@ -17,7 +17,7 @@ ${expectation_file}= vehicles-temporal-representation-021-03-expe *** Test Cases *** -Query the temporal evolution of the last N instances of entities attributes +021_03_01 Query the temporal evolution of the last N instances of entities attributes [Documentation] Check that you can query the temporal evolution of the last N instances of entities attributes [Tags] te-query 5_7_4 ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Vehicle diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_04.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_04.robot index 6bab8c04..0bf4cc60 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_04.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_04.robot @@ -17,7 +17,7 @@ ${expectation_file}= vehicles-temporal-representation-021-04-expe *** Test Cases *** -Query the temporal evolution of entities using a context +021_04 Query the temporal evolution of entities using a context [Documentation] Check that you can query the temporal evolution of entities using a context [Tags] te-query 5_7_4 ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Vehicle diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_05.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_05.robot index 57300cf3..ec356ffe 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_05.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_05.robot @@ -18,7 +18,7 @@ ${expectation_file}= vehicles-temporal-representation-021-05-expectation. *** Test Cases *** -Query the temporal evolution of entities matching the given type(s) +021_05_01 Query the temporal evolution of entities matching the given type(s) [Documentation] Check that you can query the temporal evolution of entities matching the given type(s) [Tags] te-query 5_7_4 ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Bus diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_06.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_06.robot index 5d94d9bf..5eef64e1 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_06.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_06.robot @@ -17,7 +17,7 @@ ${expectation_file}= vehicles-temporal-representation-021-06-expe *** Test Cases *** -Query the temporal evolution of entities matching the given identifier(s) +021_06_01 Query the temporal evolution of entities matching the given identifier(s) [Documentation] Check that you can query the temporal evolution of entities matching the given identifier(s) [Tags] te-query 5_7_4 ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Vehicle diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_07.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_07.robot index 4fca7480..f36be849 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_07.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_07.robot @@ -17,7 +17,7 @@ ${expectation_file}= vehicles-temporal-representation-021-07-expe *** Test Cases *** -Query the temporal evolution of entities matching the given id pattern +021_07_01 Query the temporal evolution of entities matching the given id pattern [Documentation] Check that you can query the temporal evolution of entities matching the given id pattern [Tags] te-query 5_7_4 ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Vehicle diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_08.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_08.robot index c49aaa1a..e9bb4619 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_08.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_08.robot @@ -17,7 +17,7 @@ ${expectation_file}= vehicles-temporal-representation-021-08-expe *** Test Cases *** -Query the temporal evolution of entities matching the given NGSI-LD query +021_08_01 Query the temporal evolution of entities matching the given NGSI-LD query [Documentation] Check that you can query the temporal evolution of entities matching the given NGSI-LD query [Tags] te-query 5_7_4 ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Vehicle diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_09.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_09.robot index bc439716..eb5c8f27 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_09.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_09.robot @@ -18,9 +18,9 @@ ${expectation_file}= vehicles-temporal-representation-021-09-expe *** Test Cases *** GEOREL GEOMETRY COORDINATES GEOPROPERTY EXPECTATION_FILE -Near Point [Tags] te-query 5_7_4 +021_09_01 Near Point [Tags] te-query 5_7_4 near;maxDistance==2000 Point [-8.503,41.202] ${EMPTY} vehicles-temporal-representation-021-09-01-expectation.jsonld -Within Polygon [Tags] te-query 5_7_4 +021_09_02 Within Polygon [Tags] te-query 5_7_4 contains Polygon [[[-13.503,47.202],[6.541, 52.961],[20.37,44.653],[9.46,32.57],[-13.503,32.57],[-13.503,47.202]]] location vehicles-temporal-representation-021-09-02-expectation.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_10.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_10.robot index 13ee2575..63e9df2e 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_10.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_10.robot @@ -17,7 +17,7 @@ ${context_source_url}= http://${context_source_ *** Test Cases *** -Query the temporal evolution of entities matching the given NGSI-LD context source filter +021_10_01 Query the temporal evolution of entities matching the given NGSI-LD context source filter [Documentation] Check that you can query the temporal evolution of entities matching the given NGSI-LD Context Source filter [Tags] te-query 5_7_4 ${entity_types_to_be_retrieved}= Catenate SEPARATOR=, Building diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_12.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_12.robot index 459ed342..6a12d51f 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_12.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_12.robot @@ -15,7 +15,7 @@ ${vehicle_payload_file}= 2020-08-vehicule-temporal-representation-sample.json *** Test Cases *** -Query the temporal evolution of entities with an invalid request +021_12_01 Query the temporal evolution of entities with an invalid request [Documentation] Check that you cannot query the temporal evolution of entities with an invalid request [Tags] te-query 5_7_4 ${response}= Query Temporal Representation Of Entities diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot index 688ffda7..1767587b 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_01.robot @@ -16,7 +16,7 @@ ${vehicle_expectation_file}= vehicle-temporal-representation-020-01-expectati *** Test Cases *** -Retrieve the temporal evolution of an entity +020_01_01 Retrieve the temporal evolution of an entity [Documentation] Check that you can retrieve the temporal evolution of an entity [Tags] te-retrieve 5_7_3 ${response}= Retrieve Temporal Representation Of Entity ${temporal_entity_representation_id} diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot index db67528d..3a36ea28 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_02.robot @@ -16,7 +16,7 @@ ${vehicle_expectation_file}= vehicle-temporal-representation-020-02-expectati *** Test Cases *** -Retrieve the temporal evolution of an entity using a context +020_02_01 Retrieve the temporal evolution of an entity using a context [Documentation] Check that you can retrieve the temporal evolution of an entity using a context [Tags] te-retrieve 5_7_3 ${response}= Retrieve Temporal Representation Of Entity diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot index d6ffa927..fa2b9792 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_03.robot @@ -16,7 +16,7 @@ ${vehicle_expectation_file}= vehicle-temporal-representation-020-03-expectati *** Test Cases *** -Retrieve the temporal evolution of certain attributes of an entity +020_03_01 Retrieve the temporal evolution of certain attributes of an entity [Documentation] Check that you can retrieve the temporal evolution of certain attributes of an entity [Tags] te-retrieve 5_7_3 @{temporal_attributes_to_be_retrieved}= Create List fuelLevel diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_06.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_06.robot index 01262715..150e8417 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_06.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_06.robot @@ -7,7 +7,7 @@ Resource ${EXECDIR}/resources/JsonUtils.resource *** Test Cases *** -Retrieve the temporal evolution of an entity with an invalid id +020_06_01 Retrieve the temporal evolution of an entity with an invalid id [Documentation] Check that you cannot retrieve the temporal evolution of an entity with an invalid id (invalid URI) [Tags] te-retrieve 5_7_3 ${response}= Retrieve Temporal Representation Of Entity invalidUri diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_07.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_07.robot index 6e6a1d42..c7abd006 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_07.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_07.robot @@ -7,7 +7,7 @@ Resource ${EXECDIR}/resources/JsonUtils.resource *** Test Cases *** -Retrieve the temporal evolution of a non-existing entity +020_07_01 Retrieve the temporal evolution of a non-existing entity [Documentation] Check that you cannot retrieve the temporal evolution of a non-existing entity [Tags] te-retrieve 5_7_3 ${response}= Retrieve Temporal Representation Of Entity urn:ngsi-ld:Vehicle:unknowEntity diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_08.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_08.robot index e457cb4c..8c62989f 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_08.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_08.robot @@ -15,7 +15,7 @@ ${vehicle_payload_file}= 2020-08-vehicule-temporal-representation-sample.json *** Test Cases *** -Retrieve the temporal evolution of non-existing entity attributes +020_08_01 Retrieve the temporal evolution of non-existing entity attributes [Documentation] Check that you cannot retrieve the temporal evolution of non-existing entity attributes [Tags] te-retrieve 5_7_3 @{temporal_attributes_to_be_retrieved}= Create List unknownAttribute diff --git a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot index 69e8d9f6..2e50888c 100644 --- a/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot +++ b/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_10.robot @@ -16,7 +16,7 @@ ${vehicle_expectation_file}= vehicle-temporal-representation-020-10-expectati *** Test Cases *** -Retrieve the temporal evolution of an entity with the simplified temporal representation +020_10_01 Retrieve the temporal evolution of an entity with the simplified temporal representation [Documentation] Check that you can retrieve the temporal evolution of an entity with the simplified temporal representation [Tags] te-retrieve 5_7_3 @{options}= Create List temporalValues diff --git a/doc/analysis/checks.py b/doc/analysis/checks.py index 17d68a16..613a1721 100644 --- a/doc/analysis/checks.py +++ b/doc/analysis/checks.py @@ -98,9 +98,9 @@ class Checks: 'position': [] }, 'Check Response Body Containing List Containing EntityTemporal elements': { - 'params': ['timeRel', 'timeAt'], - 'position': [] - }, + 'params': ['filename', 'entity_ids'], + 'position': [1, 2] + }, 'Check Response Body Containing List Containing Subscription elements': { 'params': ['number'], 'position': [] @@ -226,12 +226,12 @@ class Checks: @staticmethod def check_response_body_containing_list_containing_entitytemporal_elements(kwargs: list) -> str: - if "timeRel" in kwargs and "timeAt" in kwargs: - return (f"Response Body containing a list containing EntityTemporal elements containing entity type in the " - f"list of entity types provided and entity id matching id pattern provided and attribute instances " - f"'{kwargs['timeRel']}' '{kwargs['timeAt']}'") + if 'filename' in kwargs and 'entity_ids' in kwargs: + return (f"Request response body containing a list that contains Entity Temporal Elements\n" + f" compared with file '{kwargs['filename']}'\n" + f" and using the list of entity ids define in '{kwargs['entity_ids']}'") else: - raise Exception(f'ERROR, timeRel and/or timeAt attributes were not provided, but received: {kwargs}') + raise Exception(f"ERROR, expected parameters 'filename' and 'entity_ids', but received '{kwargs}'") @staticmethod def check_response_body_containing_subscription_element(kwargs: list) -> str: diff --git a/doc/analysis/generaterobotdata.py b/doc/analysis/generaterobotdata.py index cfd37157..234597fd 100644 --- a/doc/analysis/generaterobotdata.py +++ b/doc/analysis/generaterobotdata.py @@ -26,13 +26,14 @@ class GenerateRobotData: self.identifier = { 'ContextInformation': 'CI', 'CommonBehaviours': 'CB', - 'Consumption': 'CONS', + 'Consumption': 'Cons', + 'Provision': 'Prov', 'Discovery/RetrieveAvailableAttributeInformation': 'DISC', 'Discovery/RetrieveAvailableEntityTypeInformation': 'DISC', 'Entity/RetrieveEntity': 'E', 'Entities/CreateEntity': 'E', 'Entity/QueryEntities': 'E', - 'Provision': 'Prov' + 'TemporalEntity/QueryTemporalEvolutionOfEntities': 'TE' } self.references = { 'v1.3.1': 'ETSI GS CIM 009 V1.3.1 [], clause ' diff --git a/doc/analysis/parserobotfile.py b/doc/analysis/parserobotfile.py index 7c64103c..d16ce897 100644 --- a/doc/analysis/parserobotfile.py +++ b/doc/analysis/parserobotfile.py @@ -216,7 +216,6 @@ class ParseRobotFile: for i in range(0, len(position_params['position'])): param_key = position_params['params'][i] param_position = position_params['position'][i] - # param_value = self.variables[params[param_position]-1] param_value = self.get_param_value(position=params[param_position-1]) param[param_key] = param_value diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index 9bfba3e5..dffec4f6 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -68,6 +68,9 @@ class Requests: 'Query Entities': { 'positions': [0, 1], 'params': ['entity_ids', 'entity_types', 'accepts'] + }, + 'Retrieve Temporal Representation Of Entity': { + 'params': ['entity_ids', 'entity_types', 'accepts'] } } diff --git a/doc/files/019_01_01.json b/doc/files/019_01_01.json index 0d09061c..9c1d3532 100644 --- a/doc/files/019_01_01.json +++ b/doc/files/019_01_01.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_01", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_01_01", "test_objective": "Check that you can query several entities based on ids", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_01_01 Query several entities based on ids", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_01", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_01_01", "doc": "Check that you can query several entities based on ids", "tags": [ "5_7_2", diff --git a/doc/files/019_01_03.json b/doc/files/019_01_03.json index 57c24c27..5158e2d9 100644 --- a/doc/files/019_01_03.json +++ b/doc/files/019_01_03.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_03", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_01_03", "test_objective": "Check that you can query several entities based on the given id pattern", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_01_03 Query several entities based on the given id pattern", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_03", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_01_03", "doc": "Check that you can query several entities based on the given id pattern", "tags": [ "5_7_2", diff --git a/doc/files/019_01_04.json b/doc/files/019_01_04.json index 8b442220..b6e04430 100644 --- a/doc/files/019_01_04.json +++ b/doc/files/019_01_04.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_04", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_01_04", "test_objective": "Check that you can query several entities based on attribute names", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_01_04 Query several entities based on attribute names", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_01_04", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_01_04", "doc": "Check that you can query several entities based on attribute names", "tags": [ "5_7_2", diff --git a/doc/files/019_02_01.json b/doc/files/019_02_01.json index 13a78d72..02569888 100644 --- a/doc/files/019_02_01.json +++ b/doc/files/019_02_01.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_02_01", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_02_01", "test_objective": "Check that you can query several entities via POST Interaction based on ids", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_02_01 Query several entities via POST Interaction based on ids", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_02_01", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_02_01", "doc": "Check that you can query several entities via POST Interaction based on ids", "tags": [ "5_7_2", diff --git a/doc/files/019_02_03.json b/doc/files/019_02_03.json index 8307d4aa..9042909e 100644 --- a/doc/files/019_02_03.json +++ b/doc/files/019_02_03.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_02_03", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_02_03", "test_objective": "Check that you can query several entities via POST Interaction based on the given id pattern", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_02_03 Query several entities via POST Interaction based on the given id pattern", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_02_03", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_02_03", "doc": "Check that you can query several entities via POST Interaction based on the given id pattern", "tags": [ "5_7_2", diff --git a/doc/files/019_03_01.json b/doc/files/019_03_01.json index ecac878a..9f31585b 100644 --- a/doc/files/019_03_01.json +++ b/doc/files/019_03_01.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_01", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_03_01", "test_objective": "Check that you cannot query entities if the requested ids are incorrect", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_03_01 Query entities based on incorrect ids", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_01", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_03_01", "doc": "Check that you cannot query entities if the requested ids are incorrect", "tags": [ "5_7_2", diff --git a/doc/files/019_03_02.json b/doc/files/019_03_02.json index fad12f0e..3250d0df 100644 --- a/doc/files/019_03_02.json +++ b/doc/files/019_03_02.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_02", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_03_02", "test_objective": "Check that you cannot query entities if the requested entity types are incorrect", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_03_02 Query entities based on incorrect entity types", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_02", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_03_02", "doc": "Check that you cannot query entities if the requested entity types are incorrect", "tags": [ "5_7_2", diff --git a/doc/files/019_03_03.json b/doc/files/019_03_03.json index 0875c05c..0d03de11 100644 --- a/doc/files/019_03_03.json +++ b/doc/files/019_03_03.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_03", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_03_03", "test_objective": "Check that you cannot query entities if the requested id pattern is incorrect", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.2", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_03_03 Query several entities based on incorrect id pattern", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_03_03", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_03_03", "doc": "Check that you cannot query entities if the requested id pattern is incorrect", "tags": [ "5_7_2", diff --git a/doc/files/019_04.json b/doc/files/019_04.json index cf11538d..244d6875 100644 --- a/doc/files/019_04.json +++ b/doc/files/019_04.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_04", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_04", "test_objective": "Check that the queried entities by Id can be returned in a simplified representation", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.7", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_04_01 Query entities in a simplified representation", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_04_01", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_04_01", "doc": "Check that the queried entities by Id can be returned in a simplified representation", "tags": [ "6_3_7", diff --git a/doc/files/019_05.json b/doc/files/019_05.json index c2da3830..2dc50499 100644 --- a/doc/files/019_05.json +++ b/doc/files/019_05.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/E/019_05", + "tp_id": "TP/NGSI-LD/CI/Cons/E/019_05", "test_objective": "Check that the queried entities by id can be returned in a geoJSON format", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 6.3.7", "config_id": "", @@ -13,7 +13,7 @@ "test_cases": [ { "name": "019_05_01 Get an entity by id that can be returned in a geoJSON format", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/E/019_05_01", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_05_01", "doc": "Check that the queried entities by id can be returned in a geoJSON format", "tags": [ "6_3_7", diff --git a/doc/files/021_02.json b/doc/files/021_02.json new file mode 100644 index 00000000..a4c7f0eb --- /dev/null +++ b/doc/files/021_02.json @@ -0,0 +1,35 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Cons/TE/021_02", + "test_objective": "Check that you can query the temporal evolution of certain attributes of entities", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.4", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_7_4", + "keywords": [ + "Setup Initial Entities", + "Delete Initial Entities" + ], + "teardown": "Delete Initial Entities", + "initial_condition": "with {\n the SUT in the \"initial state\"\n}", + "test_cases": [ + { + "name": "021_02_01 Query the temporal evolution of certain attributes of entities", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/TE/021_02_01", + "doc": "Check that you can query the temporal evolution of certain attributes of entities", + "tags": [ + "5_7_4", + "te-query" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response containing:\n Request response body containing a list that contains Entity Temporal Elements\n compared with file 'vehicles-temporal-representation-021-02-expectation.jsonld'\n and using the list of entity ids define in '${temporal_entities_representation_ids}' and\n Response Status Code set to 200\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/temporal/entities'\n method set to 'GET'\n Response containing:\n * Entity-Type is equal to '${entity_types_to_be_retrieved}'\n * timeRel is equal to 'after'\n * timeAt is equal to '2020-07-01T12:05:00Z'\n * Accept is equal to 'attrs=${temporal_attributes_to_be_retrieved}'", + "http_verb": "GET", + "endpoint": "temporal/entities" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities", + "robotfile": "021_02" +} \ No newline at end of file diff --git a/doc/files/024_01.json b/doc/files/024_01.json index dd8ddea6..c66a70b3 100644 --- a/doc/files/024_01.json +++ b/doc/files/024_01.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/DISC/024_01", + "tp_id": "TP/NGSI-LD/CI/Cons/DISC/024_01", "test_objective": "Check that you cannot retrieve a detailed representation of an unknown NGSI-LD entity type", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.7", "config_id": "", @@ -14,7 +14,7 @@ "test_cases": [ { "name": "024_01_01 Retrieve Detailed Representation Of Available Entity Type Without Context", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/DISC/024_01_01", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/DISC/024_01_01", "doc": "Check that you cannot retrieve a detailed representation of an unknown NGSI-LD entity type", "tags": [ "5_7_7", diff --git a/doc/files/024_02.json b/doc/files/024_02.json index e2a306fb..ebce59c0 100644 --- a/doc/files/024_02.json +++ b/doc/files/024_02.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/DISC/024_02", + "tp_id": "TP/NGSI-LD/CI/Cons/DISC/024_02", "test_objective": "Check that you can retrieve a detailed representation of a specified NGSI-LD entity type", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.7", "config_id": "", @@ -14,7 +14,7 @@ "test_cases": [ { "name": "024_02_01 Retrieve Detailed Representation Of Available Entity Type", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/DISC/024_02_01", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/DISC/024_02_01", "doc": "Check that you can retrieve a detailed representation of a specified NGSI-LD entity type", "tags": [ "5_7_7", diff --git a/doc/files/027_01.json b/doc/files/027_01.json index 28ab0771..b75b35f4 100644 --- a/doc/files/027_01.json +++ b/doc/files/027_01.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/DISC/027_01", + "tp_id": "TP/NGSI-LD/CI/Cons/DISC/027_01", "test_objective": "Check that you cannot retrieve a detailed representation of an unknown NGSI-LD attribute", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.10", "config_id": "", @@ -14,7 +14,7 @@ "test_cases": [ { "name": "027_01_01 Retrieve Detailed Representation Of Available Attribute Without Context", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/DISC/027_01_01", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/DISC/027_01_01", "doc": "Check that you cannot retrieve a detailed representation of an unknown NGSI-LD attribute", "tags": [ "5_7_10", diff --git a/doc/files/027_02.json b/doc/files/027_02.json index 9ba848b4..6401e71b 100644 --- a/doc/files/027_02.json +++ b/doc/files/027_02.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/CONS/DISC/027_02", + "tp_id": "TP/NGSI-LD/CI/Cons/DISC/027_02", "test_objective": "Check that you can retrieve a list with a detailed representation of NGSI-LD attributes", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.7.10", "config_id": "", @@ -14,7 +14,7 @@ "test_cases": [ { "name": "027_02_01 Retrieve Detailed Representation Of Available Attribute", - "permutation_tp_id": "TP/NGSI-LD/CI/CONS/DISC/027_02_01", + "permutation_tp_id": "TP/NGSI-LD/CI/Cons/DISC/027_02_01", "doc": "Check that you can retrieve a list with a detailed representation of NGSI-LD attributes", "tags": [ "5_7_10", diff --git a/doc/tests/test_ContextInformation_Consumption.py b/doc/tests/test_ContextInformation_Consumption.py index a8f18e19..99bd21e6 100644 --- a/doc/tests/test_ContextInformation_Consumption.py +++ b/doc/tests/test_ContextInformation_Consumption.py @@ -204,3 +204,76 @@ class TestCIConsumptions(TestCase): def test_018_06(self): self.fail("(018_06) Test Suite with Test Template, not yet implemented") + + def test_021_01(self): + self.fail("(021_01) Test Suite with Test Template, not yet implemented") + + def test_021_02(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_02.robot' + expected_value = f'{self.folder_test_suites}/doc/files/021_02.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_021_02.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_021_03(self): + self.fail("(021_03) Problems with Request parameters, 'Query Temporal Representation Of Entities'") + + def test_021_04(self): + self.fail("(021_04) Problems with Request parameters, 'Query Temporal Representation Of Entities'") + + def test_021_05(self): + self.fail("(021_05) Problems with Request parameters, 'Query Temporal Representation Of Entities'") + + def test_021_06(self): + self.fail("(021_06) Problems with Request parameters, 'Query Temporal Representation Of Entities'") + + def test_021_07(self): + self.fail("(021_07) Problems with Request parameters, 'Query Temporal Representation Of Entities'") + + def test_021_08(self): + self.fail("(021_08) Problems with Request parameters, 'Query Temporal Representation Of Entities'") + + def test_021_09(self): + self.fail("(021_09) Test Suite with Test Template, not yet implemented") + + def test_021_10(self): + self.fail("(021_10) Problems with Request parameters, 'Query Temporal Representation Of Entities'") + + def test_021_11(self): + self.fail("(021_11) Test Suite with Test Template, not yet implemented") + + def test_021_12(self): + self.fail("(021_12) Problems with Request parameters, 'Query Temporal Representation Of Entities'") + + def test_021_13(self): + self.fail("(021_13) Test Suite with Test Template, not yet implemented") + + def test_020_01(self): + self.fail("(020_01) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'") + + def test_020_02(self): + self.fail("(020_02) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'") + + def test_020_03(self): + self.fail("(020_03) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'") + + def test_020_04(self): + self.fail("(020_04) Test Suite with Test Template, not yet implemented") + + def test_020_05(self): + self.fail("(020_05) Test Suite with Test Template, not yet implemented") + + def test_020_06(self): + self.fail("(020_06) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'") + + def test_020_07(self): + self.fail("(020_07) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'") + + def test_020_08(self): + self.fail("(020_08) Problems with Request parameters, 'Retrieve Temporal Representation Of Entity'") + + def test_020_09(self): + self.fail("(020_09) Test Suite with Test Template, not yet implemented") + + def test_020_10(self): + self.fail("(020_10) Test Suite with Test Template, not yet implemented") -- GitLab From 4b4a15722a7015845a06f573180385e0a08d0d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez=20Aguilar?= Date: Fri, 29 Sep 2023 16:00:49 +0200 Subject: [PATCH 9/9] Organize the ContextInformation/Consumption folder and start with the ContextInformation/Provision Test Suites --- .../Consumption}/019_01_01.json | 0 .../Consumption}/019_01_03.json | 0 .../Consumption}/019_01_04.json | 0 .../Consumption}/019_02_01.json | 0 .../Consumption}/019_02_03.json | 0 .../Consumption}/019_03_01.json | 0 .../Consumption}/019_03_02.json | 0 .../Consumption}/019_03_03.json | 0 .../Consumption}/019_04.json | 0 .../Consumption}/019_05.json | 0 .../Consumption}/021_02.json | 0 .../Consumption}/024_01.json | 0 .../Consumption}/024_02.json | 0 .../Consumption}/027_01.json | 0 .../Consumption}/027_02.json | 0 .../test_ContextInformation_Consumption.py | 30 +++++------ .../test_ContextInformation_Provision.py | 52 +++++++++++++++++++ 17 files changed, 67 insertions(+), 15 deletions(-) rename doc/files/{ => ContextInformation/Consumption}/019_01_01.json (100%) rename doc/files/{ => ContextInformation/Consumption}/019_01_03.json (100%) rename doc/files/{ => ContextInformation/Consumption}/019_01_04.json (100%) rename doc/files/{ => ContextInformation/Consumption}/019_02_01.json (100%) rename doc/files/{ => ContextInformation/Consumption}/019_02_03.json (100%) rename doc/files/{ => ContextInformation/Consumption}/019_03_01.json (100%) rename doc/files/{ => ContextInformation/Consumption}/019_03_02.json (100%) rename doc/files/{ => ContextInformation/Consumption}/019_03_03.json (100%) rename doc/files/{ => ContextInformation/Consumption}/019_04.json (100%) rename doc/files/{ => ContextInformation/Consumption}/019_05.json (100%) rename doc/files/{ => ContextInformation/Consumption}/021_02.json (100%) rename doc/files/{ => ContextInformation/Consumption}/024_01.json (100%) rename doc/files/{ => ContextInformation/Consumption}/024_02.json (100%) rename doc/files/{ => ContextInformation/Consumption}/027_01.json (100%) rename doc/files/{ => ContextInformation/Consumption}/027_02.json (100%) create mode 100644 doc/tests/test_ContextInformation_Provision.py diff --git a/doc/files/019_01_01.json b/doc/files/ContextInformation/Consumption/019_01_01.json similarity index 100% rename from doc/files/019_01_01.json rename to doc/files/ContextInformation/Consumption/019_01_01.json diff --git a/doc/files/019_01_03.json b/doc/files/ContextInformation/Consumption/019_01_03.json similarity index 100% rename from doc/files/019_01_03.json rename to doc/files/ContextInformation/Consumption/019_01_03.json diff --git a/doc/files/019_01_04.json b/doc/files/ContextInformation/Consumption/019_01_04.json similarity index 100% rename from doc/files/019_01_04.json rename to doc/files/ContextInformation/Consumption/019_01_04.json diff --git a/doc/files/019_02_01.json b/doc/files/ContextInformation/Consumption/019_02_01.json similarity index 100% rename from doc/files/019_02_01.json rename to doc/files/ContextInformation/Consumption/019_02_01.json diff --git a/doc/files/019_02_03.json b/doc/files/ContextInformation/Consumption/019_02_03.json similarity index 100% rename from doc/files/019_02_03.json rename to doc/files/ContextInformation/Consumption/019_02_03.json diff --git a/doc/files/019_03_01.json b/doc/files/ContextInformation/Consumption/019_03_01.json similarity index 100% rename from doc/files/019_03_01.json rename to doc/files/ContextInformation/Consumption/019_03_01.json diff --git a/doc/files/019_03_02.json b/doc/files/ContextInformation/Consumption/019_03_02.json similarity index 100% rename from doc/files/019_03_02.json rename to doc/files/ContextInformation/Consumption/019_03_02.json diff --git a/doc/files/019_03_03.json b/doc/files/ContextInformation/Consumption/019_03_03.json similarity index 100% rename from doc/files/019_03_03.json rename to doc/files/ContextInformation/Consumption/019_03_03.json diff --git a/doc/files/019_04.json b/doc/files/ContextInformation/Consumption/019_04.json similarity index 100% rename from doc/files/019_04.json rename to doc/files/ContextInformation/Consumption/019_04.json diff --git a/doc/files/019_05.json b/doc/files/ContextInformation/Consumption/019_05.json similarity index 100% rename from doc/files/019_05.json rename to doc/files/ContextInformation/Consumption/019_05.json diff --git a/doc/files/021_02.json b/doc/files/ContextInformation/Consumption/021_02.json similarity index 100% rename from doc/files/021_02.json rename to doc/files/ContextInformation/Consumption/021_02.json diff --git a/doc/files/024_01.json b/doc/files/ContextInformation/Consumption/024_01.json similarity index 100% rename from doc/files/024_01.json rename to doc/files/ContextInformation/Consumption/024_01.json diff --git a/doc/files/024_02.json b/doc/files/ContextInformation/Consumption/024_02.json similarity index 100% rename from doc/files/024_02.json rename to doc/files/ContextInformation/Consumption/024_02.json diff --git a/doc/files/027_01.json b/doc/files/ContextInformation/Consumption/027_01.json similarity index 100% rename from doc/files/027_01.json rename to doc/files/ContextInformation/Consumption/027_01.json diff --git a/doc/files/027_02.json b/doc/files/ContextInformation/Consumption/027_02.json similarity index 100% rename from doc/files/027_02.json rename to doc/files/ContextInformation/Consumption/027_02.json diff --git a/doc/tests/test_ContextInformation_Consumption.py b/doc/tests/test_ContextInformation_Consumption.py index 99bd21e6..7590921c 100644 --- a/doc/tests/test_ContextInformation_Consumption.py +++ b/doc/tests/test_ContextInformation_Consumption.py @@ -44,14 +44,14 @@ class TestCIConsumptions(TestCase): def test_027_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01.robot' - expected_value = f'{self.folder_test_suites}/doc/files/027_01.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/027_01.json' difference_file = f'{self.folder_test_suites}/doc/results/out_027_01.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_027_02(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_02.robot' - expected_value = f'{self.folder_test_suites}/doc/files/027_02.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/027_02.json' difference_file = f'{self.folder_test_suites}/doc/results/out_027_02.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) @@ -70,21 +70,21 @@ class TestCIConsumptions(TestCase): def test_024_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_01.robot' - expected_value = f'{self.folder_test_suites}/doc/files/024_01.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/024_01.json' difference_file = f'{self.folder_test_suites}/doc/results/out_024_01.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_024_02(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableEntityTypeInformation/024_02.robot' - expected_value = f'{self.folder_test_suites}/doc/files/024_02.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/024_02.json' difference_file = f'{self.folder_test_suites}/doc/results/out_024_02.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_019_01_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_01.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_01_01.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_01_01.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_01.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) @@ -94,14 +94,14 @@ class TestCIConsumptions(TestCase): def test_019_01_03(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_03.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_01_03.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_01_03.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_03.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_019_01_04(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_01_04.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_01_04.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_01_04.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_01_04.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) @@ -111,7 +111,7 @@ class TestCIConsumptions(TestCase): def test_019_02_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_01.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_02_01.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_02_01.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_02_01.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) @@ -121,7 +121,7 @@ class TestCIConsumptions(TestCase): def test_019_02_03(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_02_03.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_02_03.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_02_03.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_02_03.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) @@ -134,21 +134,21 @@ class TestCIConsumptions(TestCase): def test_019_03_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_01.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_03_01.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_03_01.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_03_01.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_019_03_02(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_02.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_03_02.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_03_02.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_03_02.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_019_03_03(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_03_03.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_03_03.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_03_03.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_03_03.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) @@ -161,7 +161,7 @@ class TestCIConsumptions(TestCase): def test_019_04(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_04.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_04.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_04.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_04.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) @@ -169,7 +169,7 @@ class TestCIConsumptions(TestCase): def test_019_05(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_05.robot' - expected_value = f'{self.folder_test_suites}/doc/files/019_05.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_05.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_05.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) @@ -210,7 +210,7 @@ class TestCIConsumptions(TestCase): def test_021_02(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_02.robot' - expected_value = f'{self.folder_test_suites}/doc/files/021_02.json' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/021_02.json' difference_file = f'{self.folder_test_suites}/doc/results/out_021_02.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) diff --git a/doc/tests/test_ContextInformation_Provision.py b/doc/tests/test_ContextInformation_Provision.py new file mode 100644 index 00000000..34593036 --- /dev/null +++ b/doc/tests/test_ContextInformation_Provision.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +from unittest import TestCase +from doc.analysis.generaterobotdata import GenerateRobotData +from json import load, dump +from deepdiff import DeepDiff +from os.path import dirname, exists +from os import listdir, remove, makedirs + + +class TestCIProvision(TestCase): + @classmethod + def setUpClass(cls): + TestCIProvision.folder_test_suites = dirname(dirname(dirname(__file__))) + folder_results = f'{TestCIProvision.folder_test_suites}/doc/results' + + # Check that the folder '/results' exists and if not, create it + if not exists(folder_results): + makedirs(folder_results) + else: + # Delete the /results folder + [remove(f'{folder_results}/{x}') for x in listdir(folder_results) if x.startswith('out')] + + def setUp(self) -> None: + self.folder_test_suites = dirname(dirname(dirname(__file__))) + + def common_function(self, robot_file, expected_value, difference_file): + data = GenerateRobotData(robot_file=robot_file, + execdir=self.folder_test_suites) + data.parse_robot() + obtained_response = data.get_info() + + with open(expected_value, 'r') as file: + expected_response = load(file) + + result = DeepDiff(t1=obtained_response, t2=expected_response, ignore_order=True) + + if len(result) != 0: + # There are some differences + with open(difference_file, 'w') as fp: + dump(obj=obtained_response, indent=2, fp=fp) + + assert False, f'They are some difference between the expected and obtained dictionaries: \n {result}' + + # def test_027_01(self): + # robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Discovery/RetrieveAvailableAttributeInformation/027_01.robot' + # expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/027_01.json' + # difference_file = f'{self.folder_test_suites}/doc/results/out_027_01.json' + # + # self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + # + # def test_025_01(self): + # self.fail("(025_01) Test Suite with Test Template, not yet implemented") -- GitLab