Commits (2)
*** Settings ***
Documentation Query entities with Entity Type Selection Language.
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource ${EXECDIR}/resources/JsonUtils.resource
Suite Setup Setup Initial Entities
Suite Teardown Delete Initial Entities
Test Template Query entities using Entity Type Selection Language
*** Variables ***
${entity_id_prefix} urn:ngsi-ld:MultiTypes:
${first_entity_filename} building-simple-attributes-sample.jsonld
${second_entity_filename} building-with-different-type-sample.jsonld
${third_entity_filename} building-with-two-types-sample.jsonld
${building_entity_type} Building
${parking_entity_type} Parking
${tourist_destination_entity_type} TouristDestination
*** Test Cases *** ENTITY_TYPES_SELECTION EXPECTED_ENTITIES_IDS
019_08_01 query with one type ${building_entity_type} ${first_entity_id},${third_entity_id}
019_08_02 query with the AND operator (${building_entity_type};${tourist_destination_entity_type}) ${third_entity_id}
019_08_03 query with the OR operator ${building_entity_type},${parking_entity_type} ${first_entity_id},${second_entity_id},${third_entity_id}
019_08_04 different query with the OR operator ${parking_entity_type},${tourist_destination_entity_type} ${second_entity_id},${third_entity_id}
019_08_05 query with two operators (${building_entity_type};${parking_entity_type}),${tourist_destination_entity_type} ${third_entity_id}
*** Keywords ***
Query entities using Entity Type Selection Language
[Documentation] Query entities with Entity Type Selection Language.
[Tags] e-query 4_17 5_7_2 since_v1.5.1
[Arguments] ${entity_types_selection} ${expected_entities_ids}
${entities_ids}= Split String ${expected_entities_ids} ,
@{entities_ids_list}= Create List ${entities_ids}
${response}= Query Entities
... entity_types=${entity_types_selection}
... context=${ngsild_test_suite_context}
Check Response Status Code 200 ${response.status_code}
Check Response Body Containing Entities URIS set to
... @{entities_ids_list}
... ${response.json()}
Setup Initial Entities
${first_entity_id}= Generate Random Entity Id ${entity_id_prefix}
Set Suite Variable ${first_entity_id}
${create_response1}= Create Entity Selecting Content Type
... ${first_entity_filename}
... ${first_entity_id}
... ${CONTENT_TYPE_LD_JSON}
Check Response Status Code 201 ${create_response1.status_code}
${second_entity_id}= Generate Random Entity Id ${entity_id_prefix}
Set Suite Variable ${second_entity_id}
${create_response2}= Create Entity Selecting Content Type
... ${second_entity_filename}
... ${second_entity_id}
... ${CONTENT_TYPE_LD_JSON}
Check Response Status Code 201 ${create_response2.status_code}
${third_entity_id}= Generate Random Entity Id ${entity_id_prefix}
Set Suite Variable ${third_entity_id}
${create_response3}= Create Entity Selecting Content Type
... ${third_entity_filename}
... ${third_entity_id}
... ${CONTENT_TYPE_LD_JSON}
Check Response Status Code 201 ${create_response3.status_code}
Delete Initial Entities
Delete Entity by Id ${first_entity_id}
Delete Entity by Id ${second_entity_id}
Delete Entity by Id ${third_entity_id}
{
"id": "urn:ngsi-ld:MultiTypes:randomUUID",
"type": ["Parking" ],
"@context": [
"https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
]
}
\ No newline at end of file
{
"id": "urn:ngsi-ld:MultiTypes:randomUUID",
"type": ["Building", "TouristDestination" ],
"@context": [
"https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
]
}
\ No newline at end of file
...@@ -8,6 +8,8 @@ class Checks: ...@@ -8,6 +8,8 @@ class Checks:
Checks.check_response_status_code, Checks.check_response_status_code,
'Check Response Body Containing Array Of URIs set to': 'Check Response Body Containing Array Of URIs set to':
Checks.check_response_body_containing_array_of_uris_set_to, Checks.check_response_body_containing_array_of_uris_set_to,
'Check Response Body Containing Entities URIS set to' :
Checks.check_response_body_containing_entities_uris_set_to,
'Check Created Resources Set To': 'Check Created Resources Set To':
Checks.check_created_resources_set_to, Checks.check_created_resources_set_to,
'Check Response Headers Containing Content-Type set to': 'Check Response Headers Containing Content-Type set to':
...@@ -129,6 +131,10 @@ class Checks: ...@@ -129,6 +131,10 @@ class Checks:
'params': ['expected_entities_ids', 'response_body'], 'params': ['expected_entities_ids', 'response_body'],
'position': [0, 1] 'position': [0, 1]
}, },
'Check Response Body Containing Entities URIS set to': {
'params': ['expected_entities_ids', 'response_body'],
'position': [0, 1]
},
'Check Response Body Containing ProblemDetails Element Containing Type Element set to': { 'Check Response Body Containing ProblemDetails Element Containing Type Element set to': {
'params': ['type'], 'params': ['type'],
'position': [1] 'position': [1]
...@@ -439,6 +445,10 @@ class Checks: ...@@ -439,6 +445,10 @@ class Checks:
def check_response_body_containing_array_of_uris_set_to(kwargs: list) -> str: def check_response_body_containing_array_of_uris_set_to(kwargs: list) -> str:
return 'Response Body set to an array of created entities ids' return 'Response Body set to an array of created entities ids'
@staticmethod
def check_response_body_containing_entities_uris_set_to(kwargs: list) -> str:
return 'Response Body contains entities ids'
@staticmethod @staticmethod
def check_created_resources_set_to(kwargs: list) -> str: def check_created_resources_set_to(kwargs: list) -> str:
return 'Created resources set to ${entities}' return 'Created resources set to ${entities}'
...@@ -967,6 +977,7 @@ if __name__ == "__main__": ...@@ -967,6 +977,7 @@ if __name__ == "__main__":
print(data.get_checks(checks='Check Response Status Code', print(data.get_checks(checks='Check Response Status Code',
status_code=201)) status_code=201))
print(data.get_checks(checks='Check Response Body Containing Array Of URIs set to')) print(data.get_checks(checks='Check Response Body Containing Array Of URIs set to'))
print(data.get_checks(checks='Check Response Body Containing Entities URIS set to'))
print(data.get_checks(checks='Check Created Resources Set To')) print(data.get_checks(checks='Check Created Resources Set To'))
print(data.get_checks(checks='Check Response Headers Containing Content-Type set to', print(data.get_checks(checks='Check Response Headers Containing Content-Type set to',
content_type='application/json')) content_type='application/json'))
......
{
"tp_id": "TP/NGSI-LD/CI/Cons/E/019_08",
"test_objective": "Query entities with Entity Type Selection Language.",
"reference": "ETSI GS CIM 009 V1.5.1 [], clauses 4.17, 5.7.2",
"config_id": "",
"parent_release": "v1.5.1",
"clauses": [
"4.17",
"5.7.2"
],
"pics_selection": "",
"keywords": [
"Query entities using Entity Type Selection Language",
"Setup Initial Entities",
"Delete Initial Entities"
],
"teardown": "Delete Initial Entities",
"initial_condition": "with {\n the SUT containing an initial state\n}",
"test_cases": [
{
"name": "019_08_01 query with one type",
"permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_01",
"doc": "Query entities with Entity Type Selection Language.",
"tags": [
"e-query",
"4_17",
"5_7_2",
"since_v1.5.1"
],
"setup": null,
"teardown": null,
"template": "Query entities using Entity Type Selection Language",
"then": "then {\n the SUT sends a valid Response for the operations:\n Query Entities with Response Status Code set to 200 and\n Query Entities with Response Body contains entities ids\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 Get Entities Request: and\n Query Parameter: entity_types set to '${entity_types_selection}' and\n Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
"http_verb": "GET",
"endpoint": "entities/"
},
{
"name": "019_08_02 query with the AND operator",
"permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_02",
"doc": "Query entities with Entity Type Selection Language.",
"tags": [
"e-query",
"4_17",
"5_7_2",
"since_v1.5.1"
],
"setup": null,
"teardown": null,
"template": "Query entities using Entity Type Selection Language",
"then": "then {\n the SUT sends a valid Response for the operations:\n Query Entities with Response Status Code set to 200 and\n Query Entities with Response Body contains entities ids\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 Get Entities Request: and\n Query Parameter: entity_types set to '${entity_types_selection}' and\n Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
"http_verb": "GET",
"endpoint": "entities/"
},
{
"name": "019_08_03 query with the OR operator",
"permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_03",
"doc": "Query entities with Entity Type Selection Language.",
"tags": [
"e-query",
"4_17",
"5_7_2",
"since_v1.5.1"
],
"setup": null,
"teardown": null,
"template": "Query entities using Entity Type Selection Language",
"then": "then {\n the SUT sends a valid Response for the operations:\n Query Entities with Response Status Code set to 200 and\n Query Entities with Response Body contains entities ids\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 Get Entities Request: and\n Query Parameter: entity_types set to '${entity_types_selection}' and\n Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
"http_verb": "GET",
"endpoint": "entities/"
},
{
"name": "019_08_04 different query with the OR operator",
"permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_04",
"doc": "Query entities with Entity Type Selection Language.",
"tags": [
"e-query",
"4_17",
"5_7_2",
"since_v1.5.1"
],
"setup": null,
"teardown": null,
"template": "Query entities using Entity Type Selection Language",
"then": "then {\n the SUT sends a valid Response for the operations:\n Query Entities with Response Status Code set to 200 and\n Query Entities with Response Body contains entities ids\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 Get Entities Request: and\n Query Parameter: entity_types set to '${entity_types_selection}' and\n Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
"http_verb": "GET",
"endpoint": "entities/"
},
{
"name": "019_08_05 query with two operators",
"permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_05",
"doc": "Query entities with Entity Type Selection Language.",
"tags": [
"e-query",
"4_17",
"5_7_2",
"since_v1.5.1"
],
"setup": null,
"teardown": null,
"template": "Query entities using Entity Type Selection Language",
"then": "then {\n the SUT sends a valid Response for the operations:\n Query Entities with Response Status Code set to 200 and\n Query Entities with Response Body contains entities ids\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 Get Entities Request: and\n Query Parameter: entity_types set to '${entity_types_selection}' and\n Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
"http_verb": "GET",
"endpoint": "entities/"
}
],
"permutations": [],
"robotpath": "ContextInformation/Consumption/Entity/QueryEntities",
"robotfile": "019_08"
}
\ No newline at end of file
...@@ -238,6 +238,13 @@ class TestCIConsumptions(TestCase): ...@@ -238,6 +238,13 @@ class TestCIConsumptions(TestCase):
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_019_08(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_08.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_08.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_019_08.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_018_01_01(self): def test_018_01_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_01.robot' robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_01_01.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/018_01_01.json' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/018_01_01.json'
......
...@@ -34,6 +34,15 @@ Check Response Body Containing Array Of URIs set to ...@@ -34,6 +34,15 @@ Check Response Body Containing Array Of URIs set to
[Arguments] ${expected_entities_ids} ${response_body} [Arguments] ${expected_entities_ids} ${response_body}
Lists Should Be Equal ${expected_entities_ids} ${response_body} ignore_order=True Lists Should Be Equal ${expected_entities_ids} ${response_body} ignore_order=True
Check Response Body Containing Entities URIS set to
[Arguments] ${expected_entities_ids} ${response_body}
@{response_entities_ids}= Create List
FOR ${entity} IN @{response_body}
Append To List ${response_entities_ids} ${entity['id']}
END
Lists Should Be Equal ${expected_entities_ids} ${response_entities_ids}
Check Response Body Content Check Response Body Content
[Arguments] ${expectation_filename} ${response_body} ${additional_ignored_path}=${EMPTY} [Arguments] ${expectation_filename} ${response_body} ${additional_ignored_path}=${EMPTY}
${entity_payload}= Load JSON From File ${EXECDIR}/data/entities/expectations/${expectation_filename} ${entity_payload}= Load JSON From File ${EXECDIR}/data/entities/expectations/${expectation_filename}
......