Loading TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_24.robot 0 → 100644 +98 −0 Original line number Diff line number Diff line *** Comments *** This Test Case has the same permutations and expectations than 019_13, but using Query Entities via POST instead of Query Entities for 019_13. This is why it reuses the same tests files suffixed with 019-13. *** Settings *** Documentation Check that entities can be queried via POST with a linked entity in different join types and representations Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource Test Setup Create Initial Entities And Linked Entities Test Teardown Delete Created Entities And Linked Entities Test Template Query Entities With Joins And Representations *** Variables *** ${linking_entity_filename}= building-relationship.jsonld ${linked_entity_filename}= city-minimal.jsonld *** Test Cases *** JOIN OPTIONS EXPECTATION_FILENAME 019_24_01 Query Inline Normalized [Tags] e-query 5_7_2 4_5_23 6_23 since_v1.8.1 inline ${EMPTY} linked-entity-retrieval/buildings-one-level-inline-019-13.json 019_24_02 Query Flat Normalized [Tags] e-query 5_7_2 4_5_23 6_23 since_v1.8.1 flat ${EMPTY} linked-entity-retrieval/buildings-one-level-flat-019-13.json 019_24_03 Query Inline Simplified [Tags] e-query 5_7_2 4_5_23 6_23 since_v1.8.1 inline keyValues linked-entity-retrieval/buildings-one-level-inline-simplified-019-13.json 019_24_04 Query Flat Simplified [Tags] e-query 5_7_2 4_5_23 6_23 since_v1.8.1 flat keyValues linked-entity-retrieval/buildings-one-level-flat-simplified-019-13.json *** Keywords *** Query Entities With Joins And Representations [Documentation] Check that entities can be queried with a linked entity in different join types and representations [Arguments] ${join} ${options} ${expectation_filename} ${entity_selector}= Create Dictionary type=Building @{entities}= Create List ${entity_selector} ${response}= Query Entities Via POST ... entities=${entities} ... join=${join} ... options=${options} ... context=${ngsild_test_suite_context} Check Response Status Code 200 ${response.status_code} Check Response Body Content ... expectation_filename=${expectation_filename} ... response_body=${response.json()} Create Initial Entities And Linked Entities ${first_entity_id}= Catenate ${BUILDING_ID_PREFIX}019-13-1 ${first_linked_entity_id}= Catenate ${CITY_ID_PREFIX}019-13-1 Set Suite Variable ${first_entity_id} Set Suite Variable ${first_linked_entity_id} ${create_response1}= Create Linking Entity ... linking_entity_id=${first_entity_id} ... linked_entity_id=${first_linked_entity_id} ${create_response2}= Create Entity Selecting Content Type ... filename=${linked_entity_filename} ... entity_id=${first_linked_entity_id} ... content_type=${CONTENT_TYPE_LD_JSON} Check Response Status Code 201 ${create_response2.status_code} ${second_entity_id}= Catenate ${BUILDING_ID_PREFIX}019-13-2 ${second_linked_entity_id}= Catenate ${CITY_ID_PREFIX}019-13-2 Set Suite Variable ${second_entity_id} Set Suite Variable ${second_linked_entity_id} ${create_response3}= Create Linking Entity ... linking_entity_id=${second_entity_id} ... linked_entity_id=${second_linked_entity_id} ${create_response4}= Create Entity Selecting Content Type ... filename=${linked_entity_filename} ... entity_id=${second_linked_entity_id} ... content_type=${CONTENT_TYPE_LD_JSON} Check Response Status Code 201 ${create_response4.status_code} Delete Created Entities And Linked Entities Delete Entity ${first_entity_id} Delete Entity ${first_linked_entity_id} Delete Entity ${second_entity_id} Delete Entity ${second_linked_entity_id} Create Linking Entity [Arguments] ${linking_entity_id} ${linked_entity_id} ${entity_payload}= Load JSON From File ${EXECDIR}/data/entities/${linking_entity_filename} ${entity}= Update Value To JSON ${entity_payload} $.id ${linking_entity_id} ${entity}= Update Value To JSON ${entity} $.locatedAt.object ${linked_entity_id} ${response}= Create Entity From JSON-LD Content ... ${entity} Check Response Status Code 201 ${response.status_code} RETURN ${response} doc/analysis/requests.py +11 −2 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ class Requests: 'Query Entities Via POST': { 'positions': [], 'params': ['entities', 'content_type', 'accept', 'context', 'attrs', 'geometry_property'] 'context', 'attrs', 'geometry_property', 'join', 'joinLevel', 'options', 'local'] }, 'Retrieve Temporal Representation Of Entity': { 'positions': [], Loading Loading @@ -1410,7 +1410,8 @@ class Requests: return response def query_entities_via_post(kwargs) -> str: expected_parameters = ['entities', 'content_type', 'accept', 'attrs', 'geometry_property'] expected_parameters = ['entities', 'content_type', 'accept', 'attrs', 'geometry_property', 'join', 'joinLevel', 'options', 'local'] if 'content_type' not in kwargs: kwargs['content_type'] = 'application/json' Loading @@ -1434,6 +1435,14 @@ class Requests: response = f"{response} and\n Query Parameter: attrs set to '{value}'" case 'geometry_property': response = f"{response} and\n Query Parameter: geoproperty set to '{value}'" case 'join': response = f"{response} and\n Query Parameter: join set to '{value}'" case 'joinLevel': response = f"{response} and\n Query Parameter: joinLevel set to '{value}'" case 'options': response = f"{response} and\n Query Parameter: options set to '{value}'" case 'local': response = f"{response} and\n Query Parameter: local set to '{value}'" case _: raise Exception(f"ERROR: unexpected attribute(s) {result}, the attributes expected are " f"{expected_parameters}, but received: {kwargs}") Loading doc/tests/test_ContextInformation_Consumption.py +7 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,13 @@ class TestCIConsumptions(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_019_24(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_24.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_24.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_24.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_019_25(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_25.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_25.json' Loading resources/ApiUtils/ContextInformationConsumption.resource +17 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,10 @@ Query Entities Via POST ... ${context}=${EMPTY} ... ${attrs}=${EMPTY} ... ${geometry_property}=${EMPTY} ... ${join}=${EMPTY} ... ${joinLevel}=${EMPTY} ... ${local}=${EMPTY} ... ${options}=${EMPTY} &{headers}= Create Dictionary Set To Dictionary ${headers} Content-Type ${content_type} Set To Dictionary ${headers} Accept ${accept} Loading @@ -136,6 +140,13 @@ Query Entities Via POST ... ${headers} ... Link=${context_link} END &{params}= Create Dictionary IF '${options}'!='' Set To Dictionary ${params} options=${options} END IF '${local}'!='' Set To Dictionary ${params} local=${local} &{body}= Create Dictionary Set To Dictionary ${body} type=Query ${entities_length}= Get Length ${entities} Loading @@ -147,10 +158,16 @@ Query Entities Via POST IF '${geometry_property}'!='' Set To Dictionary ${body} geometryProperty=${geometry_property} END IF '${join}'!='' Set To Dictionary ${body} join=${join} IF '${join_level}'!='' Set To Dictionary ${body} joinLevel=${joinLevel} END ${response}= POST ... url=${url}/${ENTITY_OPERATIONS_QUERY_ENDPOINT_PATH} ... json=${body} ... headers=${headers} ... params=${params} ... expected_status=any Output ${response} Query Entities Via POST RETURN ${response} Loading Loading
TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_24.robot 0 → 100644 +98 −0 Original line number Diff line number Diff line *** Comments *** This Test Case has the same permutations and expectations than 019_13, but using Query Entities via POST instead of Query Entities for 019_13. This is why it reuses the same tests files suffixed with 019-13. *** Settings *** Documentation Check that entities can be queried via POST with a linked entity in different join types and representations Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource Test Setup Create Initial Entities And Linked Entities Test Teardown Delete Created Entities And Linked Entities Test Template Query Entities With Joins And Representations *** Variables *** ${linking_entity_filename}= building-relationship.jsonld ${linked_entity_filename}= city-minimal.jsonld *** Test Cases *** JOIN OPTIONS EXPECTATION_FILENAME 019_24_01 Query Inline Normalized [Tags] e-query 5_7_2 4_5_23 6_23 since_v1.8.1 inline ${EMPTY} linked-entity-retrieval/buildings-one-level-inline-019-13.json 019_24_02 Query Flat Normalized [Tags] e-query 5_7_2 4_5_23 6_23 since_v1.8.1 flat ${EMPTY} linked-entity-retrieval/buildings-one-level-flat-019-13.json 019_24_03 Query Inline Simplified [Tags] e-query 5_7_2 4_5_23 6_23 since_v1.8.1 inline keyValues linked-entity-retrieval/buildings-one-level-inline-simplified-019-13.json 019_24_04 Query Flat Simplified [Tags] e-query 5_7_2 4_5_23 6_23 since_v1.8.1 flat keyValues linked-entity-retrieval/buildings-one-level-flat-simplified-019-13.json *** Keywords *** Query Entities With Joins And Representations [Documentation] Check that entities can be queried with a linked entity in different join types and representations [Arguments] ${join} ${options} ${expectation_filename} ${entity_selector}= Create Dictionary type=Building @{entities}= Create List ${entity_selector} ${response}= Query Entities Via POST ... entities=${entities} ... join=${join} ... options=${options} ... context=${ngsild_test_suite_context} Check Response Status Code 200 ${response.status_code} Check Response Body Content ... expectation_filename=${expectation_filename} ... response_body=${response.json()} Create Initial Entities And Linked Entities ${first_entity_id}= Catenate ${BUILDING_ID_PREFIX}019-13-1 ${first_linked_entity_id}= Catenate ${CITY_ID_PREFIX}019-13-1 Set Suite Variable ${first_entity_id} Set Suite Variable ${first_linked_entity_id} ${create_response1}= Create Linking Entity ... linking_entity_id=${first_entity_id} ... linked_entity_id=${first_linked_entity_id} ${create_response2}= Create Entity Selecting Content Type ... filename=${linked_entity_filename} ... entity_id=${first_linked_entity_id} ... content_type=${CONTENT_TYPE_LD_JSON} Check Response Status Code 201 ${create_response2.status_code} ${second_entity_id}= Catenate ${BUILDING_ID_PREFIX}019-13-2 ${second_linked_entity_id}= Catenate ${CITY_ID_PREFIX}019-13-2 Set Suite Variable ${second_entity_id} Set Suite Variable ${second_linked_entity_id} ${create_response3}= Create Linking Entity ... linking_entity_id=${second_entity_id} ... linked_entity_id=${second_linked_entity_id} ${create_response4}= Create Entity Selecting Content Type ... filename=${linked_entity_filename} ... entity_id=${second_linked_entity_id} ... content_type=${CONTENT_TYPE_LD_JSON} Check Response Status Code 201 ${create_response4.status_code} Delete Created Entities And Linked Entities Delete Entity ${first_entity_id} Delete Entity ${first_linked_entity_id} Delete Entity ${second_entity_id} Delete Entity ${second_linked_entity_id} Create Linking Entity [Arguments] ${linking_entity_id} ${linked_entity_id} ${entity_payload}= Load JSON From File ${EXECDIR}/data/entities/${linking_entity_filename} ${entity}= Update Value To JSON ${entity_payload} $.id ${linking_entity_id} ${entity}= Update Value To JSON ${entity} $.locatedAt.object ${linked_entity_id} ${response}= Create Entity From JSON-LD Content ... ${entity} Check Response Status Code 201 ${response.status_code} RETURN ${response}
doc/analysis/requests.py +11 −2 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ class Requests: 'Query Entities Via POST': { 'positions': [], 'params': ['entities', 'content_type', 'accept', 'context', 'attrs', 'geometry_property'] 'context', 'attrs', 'geometry_property', 'join', 'joinLevel', 'options', 'local'] }, 'Retrieve Temporal Representation Of Entity': { 'positions': [], Loading Loading @@ -1410,7 +1410,8 @@ class Requests: return response def query_entities_via_post(kwargs) -> str: expected_parameters = ['entities', 'content_type', 'accept', 'attrs', 'geometry_property'] expected_parameters = ['entities', 'content_type', 'accept', 'attrs', 'geometry_property', 'join', 'joinLevel', 'options', 'local'] if 'content_type' not in kwargs: kwargs['content_type'] = 'application/json' Loading @@ -1434,6 +1435,14 @@ class Requests: response = f"{response} and\n Query Parameter: attrs set to '{value}'" case 'geometry_property': response = f"{response} and\n Query Parameter: geoproperty set to '{value}'" case 'join': response = f"{response} and\n Query Parameter: join set to '{value}'" case 'joinLevel': response = f"{response} and\n Query Parameter: joinLevel set to '{value}'" case 'options': response = f"{response} and\n Query Parameter: options set to '{value}'" case 'local': response = f"{response} and\n Query Parameter: local set to '{value}'" case _: raise Exception(f"ERROR: unexpected attribute(s) {result}, the attributes expected are " f"{expected_parameters}, but received: {kwargs}") Loading
doc/tests/test_ContextInformation_Consumption.py +7 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,13 @@ class TestCIConsumptions(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_019_24(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_24.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_24.json' difference_file = f'{self.folder_test_suites}/doc/results/out_019_24.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) def test_019_25(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/QueryEntities/019_25.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/019_25.json' Loading
resources/ApiUtils/ContextInformationConsumption.resource +17 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,10 @@ Query Entities Via POST ... ${context}=${EMPTY} ... ${attrs}=${EMPTY} ... ${geometry_property}=${EMPTY} ... ${join}=${EMPTY} ... ${joinLevel}=${EMPTY} ... ${local}=${EMPTY} ... ${options}=${EMPTY} &{headers}= Create Dictionary Set To Dictionary ${headers} Content-Type ${content_type} Set To Dictionary ${headers} Accept ${accept} Loading @@ -136,6 +140,13 @@ Query Entities Via POST ... ${headers} ... Link=${context_link} END &{params}= Create Dictionary IF '${options}'!='' Set To Dictionary ${params} options=${options} END IF '${local}'!='' Set To Dictionary ${params} local=${local} &{body}= Create Dictionary Set To Dictionary ${body} type=Query ${entities_length}= Get Length ${entities} Loading @@ -147,10 +158,16 @@ Query Entities Via POST IF '${geometry_property}'!='' Set To Dictionary ${body} geometryProperty=${geometry_property} END IF '${join}'!='' Set To Dictionary ${body} join=${join} IF '${join_level}'!='' Set To Dictionary ${body} joinLevel=${joinLevel} END ${response}= POST ... url=${url}/${ENTITY_OPERATIONS_QUERY_ENDPOINT_PATH} ... json=${body} ... headers=${headers} ... params=${params} ... expected_status=any Output ${response} Query Entities Via POST RETURN ${response} Loading