From e256db21474fbe7fea97700cb289c298b3a53913 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 27 Apr 2024 15:44:15 +0200 Subject: [PATCH 1/2] feat: add test on type append in update entity attributes operation --- .../UpdateEntityAttributes/011_06.robot | 49 +++++++++++++++++++ ...ng-minimal-with-two-types-expectation.json | 4 ++ .../fragmentEntities/type-fragment.json | 6 +++ .../ContextInformation/Provision/011_06.json | 42 ++++++++++++++++ .../test_ContextInformation_Provision.py | 7 +++ 5 files changed, 108 insertions(+) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot create mode 100644 data/entities/expectations/building-minimal-with-two-types-expectation.json create mode 100644 data/entities/fragmentEntities/type-fragment.json create mode 100644 doc/files/ContextInformation/Provision/011_06.json diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot new file mode 100644 index 00000000..a376109c --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot @@ -0,0 +1,49 @@ +*** Settings *** +Documentation Check that you can update the types on an entity + +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 Entity +Test Teardown Delete Initial Entity + + +*** Variables *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${entity_filename}= building-minimal-sample.json +${type_fragment_filename}= type-fragment.json + + +*** Test Cases *** +011_06_01 Append type to an entity + [Documentation] Check that type is appended if it is not yet in the target entity + [Tags] ea-append 5_6_2 4_16 since_v1.5.1 + ${response}= Update Entity Attributes + ... ${entity_id} + ... ${type_fragment_filename} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 204 ${response.status_code} + ${expectation_filename}= Set Variable building-minimal-with-two-types-expectation.json + ${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id} + ${response}= Retrieve Entity by Id + ... ${entity_id} + ... accept=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Updated Resource Set To ${entity_expectation_payload} ${response.json()} + + +*** Keywords *** +Create Initial Entity + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + Set Test Variable ${entity_id} + ${response}= Create Entity Selecting Content Type + ... ${entity_filename} + ... ${entity_id} + ... ${CONTENT_TYPE_JSON} + ... ${ngsild_test_suite_context} + Check Response Status Code 201 ${response.status_code} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/data/entities/expectations/building-minimal-with-two-types-expectation.json b/data/entities/expectations/building-minimal-with-two-types-expectation.json new file mode 100644 index 00000000..3782f4c4 --- /dev/null +++ b/data/entities/expectations/building-minimal-with-two-types-expectation.json @@ -0,0 +1,4 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": ["Building", "Vehicle"] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/type-fragment.json b/data/entities/fragmentEntities/type-fragment.json new file mode 100644 index 00000000..e405afcc --- /dev/null +++ b/data/entities/fragmentEntities/type-fragment.json @@ -0,0 +1,6 @@ +{ + "type": "Vehicle", + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Provision/011_06.json b/doc/files/ContextInformation/Provision/011_06.json new file mode 100644 index 00000000..b31fbadf --- /dev/null +++ b/doc/files/ContextInformation/Provision/011_06.json @@ -0,0 +1,42 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/EA/011_06", + "test_objective": "Check that you can update the types on an entity", + "reference": "ETSI GS CIM 009 V1.5.1 [], clauses 4.16, 5.6.2", + "config_id": "", + "parent_release": "v1.5.1", + "clauses": [ + "4.16", + "5.6.2" + ], + "pics_selection": "", + "keywords": [ + "Create Initial Entity", + "Delete Initial Entity" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing an initial Entity ${entity} \n with an id set to ${entityId} \n}", + "test_cases": [ + { + "name": "011_06_01 Append type to an entity", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/011_06_01", + "doc": "Check that type is appended if it is not yet in the target entity", + "tags": [ + "4_16", + "5_6_2", + "ea-append", + "since_v1.5.1" + ], + "setup": "Create Initial Entity", + "teardown": "Delete Initial Entity", + "template": null, + "then": "then {\n the SUT sends a valid Response for the operations:\n Update Entity Attributes with Response Status Code set to 204 and\n Update Entity Attributes with Check Updated Entity and\n Query Parameter: 'ignored_keys' set to '${None}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/'\n method set to 'GET'\n Request Retrieve Entity by Id and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: accept set to 'application/json' and\n Query Parameter: context set to 'https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld'\n}", + "http_verb": "GET", + "endpoint": "" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes", + "robotfile": "011_06", + "error_while_autogenerating": "no error" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Provision.py b/doc/tests/test_ContextInformation_Provision.py index 679e9ed6..eb503a0f 100644 --- a/doc/tests/test_ContextInformation_Provision.py +++ b/doc/tests/test_ContextInformation_Provision.py @@ -469,6 +469,13 @@ class TestCIProvision(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_011_06(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/011_06.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_011_06.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_007_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/TemporalEntity/CreateTemporalRepresentationOfEntity/007_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/007_01.json' -- GitLab From 3edfee5bb10a4b64539482fdf4ed6dfda223eb93 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Tue, 23 Jul 2024 14:17:22 +0200 Subject: [PATCH 2/2] add permutations --- .../UpdateEntityAttributes/011_06.robot | 29 +++++++++++++------ .../building-minimal-with-three-types.json | 4 +++ ...n => building-minimal-with-two-types.json} | 0 .../type-building-fragment.json | 6 ++++ .../type-vehicle-building-fragment.json | 6 ++++ ...agment.json => type-vehicle-fragment.json} | 0 .../types-vehicle-car-fragment.json | 6 ++++ 7 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 data/entities/expectations/building-minimal-with-three-types.json rename data/entities/expectations/{building-minimal-with-two-types-expectation.json => building-minimal-with-two-types.json} (100%) create mode 100644 data/entities/fragmentEntities/type-building-fragment.json create mode 100644 data/entities/fragmentEntities/type-vehicle-building-fragment.json rename data/entities/fragmentEntities/{type-fragment.json => type-vehicle-fragment.json} (100%) create mode 100644 data/entities/fragmentEntities/types-vehicle-car-fragment.json diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot index a376109c..6a1b5a26 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/UpdateEntityAttributes/011_06.robot @@ -8,33 +8,44 @@ Resource ${EXECDIR}/resources/JsonUtils.resource Test Setup Create Initial Entity Test Teardown Delete Initial Entity +Test Template Append Types to an Entity *** Variables *** -${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: -${entity_filename}= building-minimal-sample.json -${type_fragment_filename}= type-fragment.json +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${entity_filename}= building-minimal-sample.json -*** Test Cases *** -011_06_01 Append type to an entity +*** Test Cases *** FRAGMENT_FILENAME EXPECTATION_FILENAME +011_06_01 AppendOneType + type-vehicle-fragment.json building-minimal-with-two-types.json +011_06_02 AppendTwoTypes + types-vehicle-car-fragment.json building-minimal-with-three-types.json +011_06_03 AppendExistingType + type-building-fragment.json building-minimal-compacted-expectation.json +011_06_04 AppendOneTypeAndOneExisting + type-vehicle-building-fragment.json building-minimal-with-two-types.json + + +*** Keywords *** +Append Types to an Entity [Documentation] Check that type is appended if it is not yet in the target entity [Tags] ea-append 5_6_2 4_16 since_v1.5.1 + [Arguments] ${type_fragment_filename} ${expectation_filename} + ${response}= Update Entity Attributes ... ${entity_id} ... ${type_fragment_filename} ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 204 ${response.status_code} - ${expectation_filename}= Set Variable building-minimal-with-two-types-expectation.json - ${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id} ${response}= Retrieve Entity by Id ... ${entity_id} ... accept=${CONTENT_TYPE_JSON} ... context=${ngsild_test_suite_context} + ${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id} Check Updated Resource Set To ${entity_expectation_payload} ${response.json()} - -*** Keywords *** Create Initial Entity ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} Set Test Variable ${entity_id} diff --git a/data/entities/expectations/building-minimal-with-three-types.json b/data/entities/expectations/building-minimal-with-three-types.json new file mode 100644 index 00000000..5ced7334 --- /dev/null +++ b/data/entities/expectations/building-minimal-with-three-types.json @@ -0,0 +1,4 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": ["Building", "Vehicle", "Car"] +} \ No newline at end of file diff --git a/data/entities/expectations/building-minimal-with-two-types-expectation.json b/data/entities/expectations/building-minimal-with-two-types.json similarity index 100% rename from data/entities/expectations/building-minimal-with-two-types-expectation.json rename to data/entities/expectations/building-minimal-with-two-types.json diff --git a/data/entities/fragmentEntities/type-building-fragment.json b/data/entities/fragmentEntities/type-building-fragment.json new file mode 100644 index 00000000..aa8f90d1 --- /dev/null +++ b/data/entities/fragmentEntities/type-building-fragment.json @@ -0,0 +1,6 @@ +{ + "type": "Building", + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/type-vehicle-building-fragment.json b/data/entities/fragmentEntities/type-vehicle-building-fragment.json new file mode 100644 index 00000000..6665997b --- /dev/null +++ b/data/entities/fragmentEntities/type-vehicle-building-fragment.json @@ -0,0 +1,6 @@ +{ + "type": ["Building", "Vehicle"], + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/type-fragment.json b/data/entities/fragmentEntities/type-vehicle-fragment.json similarity index 100% rename from data/entities/fragmentEntities/type-fragment.json rename to data/entities/fragmentEntities/type-vehicle-fragment.json diff --git a/data/entities/fragmentEntities/types-vehicle-car-fragment.json b/data/entities/fragmentEntities/types-vehicle-car-fragment.json new file mode 100644 index 00000000..fde75e0f --- /dev/null +++ b/data/entities/fragmentEntities/types-vehicle-car-fragment.json @@ -0,0 +1,6 @@ +{ + "type": ["Vehicle", "Car"], + "@context": [ + "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld" + ] +} \ No newline at end of file -- GitLab