From 1ae5aae03d200d80741bea83f919b25dd7c9516e Mon Sep 17 00:00:00 2001 From: ranim-n Date: Tue, 26 Nov 2024 16:08:51 +0100 Subject: [PATCH 1/2] feat: add new tcs for replace attribute endpoint --- README.md | 2 +- .../Entities/ReplaceEntity/054_01.robot | 7 +- .../Entities/ReplaceEntity/054_02.robot | 3 +- .../ReplaceEntityAttribute/055_01.robot | 73 +++++++++++++++++++ .../ReplaceEntityAttribute/055_02.robot | 73 +++++++++++++++++++ .../ReplaceEntityAttribute/055_03.robot | 62 ++++++++++++++++ .../entities/building-locatedAt-and-name.json | 5 +- .../vehicle-replace-isParked-attribute.jsonld | 36 +++++++++ ...replace-isParked-new-type-attribute.jsonld | 31 ++++++++ ...le-replace-speed-datasetid-instance.jsonld | 37 ++++++++++ ...icle-replace-speed-default-instance.jsonld | 36 +++++++++ data/entities/vehicle-isParked-attribute.json | 9 +++ .../vehicle-isParked-new-type-attribute.json | 4 + data/entities/vehicle-scope-attribute.json | 3 + .../vehicle-speed-datasetid-instance.json | 10 +++ .../vehicle-speed-default-instance.json | 8 ++ .../vehicle-speed-multi-instances.jsonld | 36 +++++++++ doc/analysis/generaterobotdata.py | 1 + doc/analysis/requests.py | 33 +++++++++ .../ContextInformation/Provision/054_01.json | 2 +- .../ContextInformation/Provision/054_02.json | 6 +- .../ContextInformation/Provision/055_01.json | 60 +++++++++++++++ .../ContextInformation/Provision/055_02.json | 60 +++++++++++++++ .../test_ContextInformation_Provision.py | 21 ++++++ .../ContextInformationProvision.resource | 21 ++++++ 25 files changed, 627 insertions(+), 12 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_01.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_02.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot create mode 100644 data/entities/expectations/vehicle-replace-isParked-attribute.jsonld create mode 100644 data/entities/expectations/vehicle-replace-isParked-new-type-attribute.jsonld create mode 100644 data/entities/expectations/vehicle-replace-speed-datasetid-instance.jsonld create mode 100644 data/entities/expectations/vehicle-replace-speed-default-instance.jsonld create mode 100644 data/entities/vehicle-isParked-attribute.json create mode 100644 data/entities/vehicle-isParked-new-type-attribute.json create mode 100644 data/entities/vehicle-scope-attribute.json create mode 100644 data/entities/vehicle-speed-datasetid-instance.json create mode 100644 data/entities/vehicle-speed-default-instance.json create mode 100644 data/entities/vehicle-speed-multi-instances.jsonld create mode 100644 doc/files/ContextInformation/Provision/055_01.json create mode 100644 doc/files/ContextInformation/Provision/055_02.json diff --git a/README.md b/README.md index efc1acfb..14439ebc 100644 --- a/README.md +++ b/README.md @@ -373,7 +373,7 @@ In these cases, it is needed to provide the corresponding information in the Pyt - When a new permutation is added in an existing Test Case, run the documentation generation script (`python doc/generateDocumentationData.py {tc_id}`) for the Test Case and copy the generated JSON file in the folder containing all files for the given group and subgroup (`cp doc/results/{tc_id}.json doc/files/{group}/{subgroup}`) -- When a new directory containing Test Cases is created, it has to be declared in `doc/generaterobotdata.py` along with +- When a new directory containing Test Cases is created, it has to be declared in `doc/analysis/generaterobotdata.py` along with its acronym Finally, check that everything is OK by running the unit tests: diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_01.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_01.robot index af978887..dffa254a 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_01.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_01.robot @@ -27,14 +27,17 @@ ${expectation_filename} building-locatedAt-and-name-normalized.jsonl ${response}= Replace Entity Selecting Content Type ... entity_id=${entity_id} ... entity_fragment=${entity} - ... content_type=${CONTENT_TYPE_LD_JSON} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} Check Response Status Code 204 ${response.status_code} ${response1}= Retrieve Entity by Id ... id=${entity_id} ... context=${ngsild_test_suite_context} ... options=sysAttrs ${ignored_attributes}= Create List @context createdAt modifiedAt - ${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id} + ${entity_expectation_payload}= Load Test Sample + ... test_sample_file_path=entities/expectations/${expectation_filename} + ... test_sample_id=${entity_id} Check Updated Resource Set To ... updated_resource=${entity_expectation_payload} ... response_body=${response1.json()} diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_02.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_02.robot index 8bd6905c..f60447e8 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_02.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_02.robot @@ -39,7 +39,8 @@ Replace an existing entity with a faulty ID ${response}= Replace Entity Selecting Content Type ... entity_id=${faulty_entity_id} ... entity_fragment=${entity} - ... content_type=${CONTENT_TYPE_LD_JSON} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} Check Response Status Code ${expected_status_code} ${response.status_code} Setup Initial Entity diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_01.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_01.robot new file mode 100644 index 00000000..e438615e --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_01.robot @@ -0,0 +1,73 @@ +*** Settings *** +Documentation Check that one can replace an existing entity attribute and that its createdAt Temporal Property remains unchanged + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Setup Setup Initial Entity +Test Teardown Delete Initial Entity +Test Template Replace Entity Attribute + + +*** Variables *** +${vehicle_id_prefix} urn:ngsi-ld:Vehicle: +${entity_filename} vehicle-speed-multi-instances.jsonld + + +*** Test Cases *** ATTRIBUTE_FILE_NAME EXPECTATION_FILE_NAME +055_01_01 Replace entity attribute + [Tags] ea-replace 5_6_19 6_7_3_3 since_v1.6.1 + vehicle-isParked-attribute.json vehicle-replace-isParked-attribute.jsonld +055_01_02 Replace entity attribute giving a new attribute type + [Tags] ea-replace 5_6_19 6_7_3_3 since_v1.6.1 + vehicle-isParked-new-type-attribute.json vehicle-replace-isParked-new-type-attribute.jsonld + + +*** Keywords *** +Replace Entity Attribute + [Documentation] Check that one can replace an existing entity attribute and that its createdAt Temporal Property remains unchanged + [Arguments] ${attribute_replacement_filename} ${expectation_filename} + ${attribute}= Load Test Sample + ... test_sample_file_path=entities/${attribute_replacement_filename} + ... test_sample_id=${entity_id} + ${response}= Replace Attribute Selecting Content Type + ... entity_id=${entity_id} + ... attr_id=isParked + ... attribute_fragment=${attribute} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + ${response1}= Retrieve Entity by Id + ... id=${entity_id} + ... context=${ngsild_test_suite_context} + ... options=sysAttrs + ${ignored_attributes}= Create List @context createdAt modifiedAt + ${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id} + Check Updated Resource Set To + ... updated_resource=${entity_expectation_payload} + ... response_body=${response1.json()} + ... ignored_keys=${ignored_attributes} + Check JSON Value In Response Body + ... json_path_expr=['isParked']['createdAt'] + ... value_to_check=${createdAt} + ... response_body=${response1.json()} + +Setup 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_LD_JSON} + Check Response Status Code 201 ${response.status_code} + ${response}= Retrieve Entity by Id + ... id=${entity_id} + ... context=${ngsild_test_suite_context} + ... options=sysAttrs + ${createdAt}= Set Variable ${response.json()['isParked']['createdAt']} + Set Test Variable ${createdAt} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_02.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_02.robot new file mode 100644 index 00000000..ac80245a --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_02.robot @@ -0,0 +1,73 @@ +*** Settings *** +Documentation Check that one can replace an existing multi-instance entity attribute and that its createdAt Temporal Property remains unchanged + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Setup Setup Initial Entity +Test Teardown Delete Initial Entity +Test Template Replace Multi Instance Entity Attribute + + +*** Variables *** +${vehicle_id_prefix} urn:ngsi-ld:Vehicle: +${entity_filename} vehicle-speed-multi-instances.jsonld + + +*** Test Cases *** ATTRIBUTE_FILE_NAME EXPECTATION_FILE_NAME +055_02_01 Replace entity attribute giving no datasetId + [Tags] ea-replace 5_6_19 6_7_3_3 since_v1.6.1 + vehicle-speed-default-instance.json vehicle-replace-speed-default-instance.jsonld +055_02_02 Replace entity attribute giving a datasetId + [Tags] ea-replace 5_6_19 6_7_3_3 since_v1.6.1 + vehicle-speed-datasetid-instance.json vehicle-replace-speed-datasetid-instance.jsonld + + +*** Keywords *** +Replace Multi Instance Entity Attribute + [Documentation] Check that one can replace an existing multi-instance entity attribute and that its createdAt Temporal Property remains unchanged + [Arguments] ${attribute_replacement_filename} ${expectation_filename} + ${attribute}= Load Test Sample + ... test_sample_file_path=entities/${attribute_replacement_filename} + ... test_sample_id=${entity_id} + ${response}= Replace Attribute Selecting Content Type + ... entity_id=${entity_id} + ... attr_id=speed + ... attribute_fragment=${attribute} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + ${response1}= Retrieve Entity by Id + ... id=${entity_id} + ... context=${ngsild_test_suite_context} + ... options=sysAttrs + ${ignored_attributes}= Create List @context createdAt modifiedAt + ${entity_expectation_payload}= Load Test Sample entities/expectations/${expectation_filename} ${entity_id} + Check Updated Resource Set To + ... updated_resource=${entity_expectation_payload} + ... response_body=${response1.json()} + ... ignored_keys=${ignored_attributes} + Check JSON Value In Response Body + ... json_path_expr=['speed'][0]['createdAt'] + ... value_to_check=${createdAt} + ... response_body=${response1.json()} + +Setup 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_LD_JSON} + Check Response Status Code 201 ${response.status_code} + ${response}= Retrieve Entity by Id + ... id=${entity_id} + ... context=${ngsild_test_suite_context} + ... options=sysAttrs + ${createdAt}= Set Variable ${response.json()['speed'][0]['createdAt']} + Set Test Variable ${createdAt} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot new file mode 100644 index 00000000..2391ef88 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot @@ -0,0 +1,62 @@ +*** Settings *** +Documentation Check that the correct error type is returned when replacing an attribute with faulty data + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Setup Setup Initial Entity +Test Teardown Delete Initial Entity +Test Template Replace Entity Attribute With Faulty Data + + +*** Variables *** +${vehicle_id_prefix} urn:ngsi-ld:Vehicle: +${entity_filename} vehicle-speed-multi-instances.jsonld + + +*** Test Cases *** ENTITY_ID ATTR_ID ATTRIBUTE_FILE_NAME EXPECTED_STATUS_CODE +055_03_01 Replace entity attribute giving an invalid entity ID + [Tags] ea-replace 5_6_19 6_7_3_3 since_v1.6.1 + invalidUri isParked vehicle-isParked-attribute.json 400 +055_03_02 Replace entity attribute giving a nonexistent entity ID + [Tags] ea-replace 5_6_19 6_7_3_3 since_v1.6.1 + urn:ngsi-ld:Vehicle:Nonexistent isParked vehicle-isParked-attribute.json 404 +055_03_03 Replace entity attribute giving an invalid attribute name + [Tags] ea-replace 5_6_19 6_7_3_3 since_v1.6.1 + ${entity_id} @invalid vehicle-isParked-attribute.json 400 +055_03_04 Replace entity attribute giving a nonexistent attribute name + [Tags] ea-replace 5_6_19 6_7_3_3 since_v1.6.1 + ${entity_id} brandName vehicle-isParked-attribute.json 404 +055_03_05 Replace entity attribute giving a scope attribute + [Tags] ea-replace 5_6_19 6_7_3_3 since_v1.6.1 + ${entity_id} scope vehicle-scope-attribute.json 400 + + +*** Keywords *** +Replace Entity Attribute With Faulty Data + [Documentation] Check that the correct error type is returned when replacing an attribute with faulty data + [Arguments] ${entity_id} ${attr_id} ${attribute_replacement_filename} ${expected_status_code} + ${attribute}= Load Test Sample + ... test_sample_file_path=entities/${attribute_replacement_filename} + ... test_sample_id=${entity_id} + ${response}= Replace Attribute Selecting Content Type + ... entity_id=${entity_id} + ... attr_id=${attr_id} + ... attribute_fragment=${attribute} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code ${expected_status_code} ${response.status_code} + +Setup 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_LD_JSON} + Check Response Status Code 201 ${response.status_code} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/data/entities/building-locatedAt-and-name.json b/data/entities/building-locatedAt-and-name.json index 9cac6ee6..e461c069 100644 --- a/data/entities/building-locatedAt-and-name.json +++ b/data/entities/building-locatedAt-and-name.json @@ -8,8 +8,5 @@ "locatedAt": { "type": "Relationship", "object": "urn:ngsi-ld:City:Pisa" - }, - "@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 diff --git a/data/entities/expectations/vehicle-replace-isParked-attribute.jsonld b/data/entities/expectations/vehicle-replace-isParked-attribute.jsonld new file mode 100644 index 00000000..54390ba4 --- /dev/null +++ b/data/entities/expectations/vehicle-replace-isParked-attribute.jsonld @@ -0,0 +1,36 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "scope": "/Madrid/Centro", + "isParked": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown2", + "observedAt": "2017-07-29T15:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + } + }, + "speed": [ + { + "type": "Property", + "value": 55, + "source": { + "type": "Property", + "value": "Speedometer" + } + }, + { + "type": "Property", + "value": 54.5, + "source": { + "type": "Property", + "value": "GPS" + }, + "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed" + } + ], + "@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 diff --git a/data/entities/expectations/vehicle-replace-isParked-new-type-attribute.jsonld b/data/entities/expectations/vehicle-replace-isParked-new-type-attribute.jsonld new file mode 100644 index 00000000..ecba2fd0 --- /dev/null +++ b/data/entities/expectations/vehicle-replace-isParked-new-type-attribute.jsonld @@ -0,0 +1,31 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "scope": "/Madrid/Centro", + "isParked": { + "type": "Property", + "value": true + }, + "speed": [ + { + "type": "Property", + "value": 55, + "source": { + "type": "Property", + "value": "Speedometer" + } + }, + { + "type": "Property", + "value": 54.5, + "source": { + "type": "Property", + "value": "GPS" + }, + "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed" + } + ], + "@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 diff --git a/data/entities/expectations/vehicle-replace-speed-datasetid-instance.jsonld b/data/entities/expectations/vehicle-replace-speed-datasetid-instance.jsonld new file mode 100644 index 00000000..0df540cf --- /dev/null +++ b/data/entities/expectations/vehicle-replace-speed-datasetid-instance.jsonld @@ -0,0 +1,37 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "scope": "/Madrid/Centro", + "isParked": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + } + }, + "speed": [ + { + "type": "Property", + "value": 55, + "source": { + "type": "Property", + "value": "Speedometer" + } + }, + { + "type": "Property", + "value": 70, + "source": { + "type": "Property", + "value": "GPS" + }, + "observedAt": "2017-07-29T11:00:04Z", + "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed" + } + ], + "@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 diff --git a/data/entities/expectations/vehicle-replace-speed-default-instance.jsonld b/data/entities/expectations/vehicle-replace-speed-default-instance.jsonld new file mode 100644 index 00000000..60a6ac48 --- /dev/null +++ b/data/entities/expectations/vehicle-replace-speed-default-instance.jsonld @@ -0,0 +1,36 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "scope": "/Madrid/Centro", + "isParked": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + } + }, + "speed": [ + { + "type": "Property", + "value": 60, + "source": { + "type": "Property", + "value": "Speedometer" + } + }, + { + "type": "Property", + "value": 54.5, + "source": { + "type": "Property", + "value": "GPS" + }, + "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed" + } + ], + "@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 diff --git a/data/entities/vehicle-isParked-attribute.json b/data/entities/vehicle-isParked-attribute.json new file mode 100644 index 00000000..f36701b1 --- /dev/null +++ b/data/entities/vehicle-isParked-attribute.json @@ -0,0 +1,9 @@ +{ + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown2", + "observedAt": "2017-07-29T15:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + } +} \ No newline at end of file diff --git a/data/entities/vehicle-isParked-new-type-attribute.json b/data/entities/vehicle-isParked-new-type-attribute.json new file mode 100644 index 00000000..c9dff961 --- /dev/null +++ b/data/entities/vehicle-isParked-new-type-attribute.json @@ -0,0 +1,4 @@ +{ + "type": "Property", + "value": true +} \ No newline at end of file diff --git a/data/entities/vehicle-scope-attribute.json b/data/entities/vehicle-scope-attribute.json new file mode 100644 index 00000000..94cad926 --- /dev/null +++ b/data/entities/vehicle-scope-attribute.json @@ -0,0 +1,3 @@ +{ + "scope":"/Company123/UnitA" +} \ No newline at end of file diff --git a/data/entities/vehicle-speed-datasetid-instance.json b/data/entities/vehicle-speed-datasetid-instance.json new file mode 100644 index 00000000..f28e9b5b --- /dev/null +++ b/data/entities/vehicle-speed-datasetid-instance.json @@ -0,0 +1,10 @@ +{ + "type": "Property", + "value": 70, + "source": { + "type": "Property", + "value": "GPS" + }, + "observedAt": "2017-07-29T11:00:04Z", + "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed" +} \ No newline at end of file diff --git a/data/entities/vehicle-speed-default-instance.json b/data/entities/vehicle-speed-default-instance.json new file mode 100644 index 00000000..db89c4e9 --- /dev/null +++ b/data/entities/vehicle-speed-default-instance.json @@ -0,0 +1,8 @@ +{ + "type": "Property", + "value": 60, + "source": { + "type": "Property", + "value": "Speedometer" + } +} diff --git a/data/entities/vehicle-speed-multi-instances.jsonld b/data/entities/vehicle-speed-multi-instances.jsonld new file mode 100644 index 00000000..3f556e3d --- /dev/null +++ b/data/entities/vehicle-speed-multi-instances.jsonld @@ -0,0 +1,36 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "scope": "/Madrid/Centro", + "isParked": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + } + }, + "speed": [ + { + "type": "Property", + "value": 55, + "source": { + "type": "Property", + "value": "Speedometer" + } + }, + { + "type": "Property", + "value": 54.5, + "source": { + "type": "Property", + "value": "GPS" + }, + "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed" + } + ], + "@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 diff --git a/doc/analysis/generaterobotdata.py b/doc/analysis/generaterobotdata.py index d90b38ce..ff408f61 100644 --- a/doc/analysis/generaterobotdata.py +++ b/doc/analysis/generaterobotdata.py @@ -49,6 +49,7 @@ class GenerateRobotData: 'EntityAttributes/AppendEntityAttributes': 'EA', 'EntityAttributes/UpdateEntityAttributes': 'EA', 'EntityAttributes/PartialAttributeUpdate': 'EA', + 'EntityAttributes/ReplaceEntityAttribute': 'EA', 'EntityAttributes/DeleteEntityAttribute': 'EA', 'BatchEntities/CreateBatchOfEntities': 'BE', 'BatchEntities/UpsertBatchOfEntities': 'BE', diff --git a/doc/analysis/requests.py b/doc/analysis/requests.py index 8a98b2f2..aec2292d 100644 --- a/doc/analysis/requests.py +++ b/doc/analysis/requests.py @@ -106,6 +106,10 @@ class Requests: 'positions': [0, 1, 2, 3], 'params': ['entity_id', 'entity_fragment', 'content_type', 'context'] }, + 'Replace Attribute Selecting Content Type': { + 'positions': [0, 1, 2, 3, 4], + 'params': ['entity_id', 'attr_id', 'attribute_fragment', 'content_type', 'context'] + }, 'Append Entity Attributes': { 'positions': [0, 1, 2], 'params': ['id', 'fragment_filename', 'content_type'] @@ -316,6 +320,8 @@ class Requests: Requests.delete_entity_by_id, 'Replace Entity Selecting Content Type': Requests.replace_entity_selecting_content_type, + 'Replace Attribute Selecting Content Type': + Requests.replace_attribute_selecting_content_type, 'Append Entity Attributes': Requests.append_entity_attributes, 'Update Entity Attributes': @@ -1383,6 +1389,33 @@ class Requests: return response + @staticmethod + def replace_attribute_selecting_content_type(kwargs) -> str: + expected_parameters = ['entity_id', 'attr_id', 'attribute_fragment', 'content_type', 'context'] + + if 'context' not in kwargs: + kwargs['context'] = '${EMPTY}' + + result = [x for x in kwargs if x not in expected_parameters] + response = "Replace Attribute Selecting Content Type" + for key, value in kwargs.items(): + match key: + case 'entity_id': + response = f"{response} and\n Query Parameter: entity_id set to '{value}'" + case 'attr_id': + response = f"{response} and\n Query Parameter: attr_id set to '{value}'" + case 'attribute_fragment': + response = f"{response} and\n Query Parameter: attribute_fragment set to '{value}'" + case 'content_type': + response = f"{response} and\n Query Parameter: content_type set to '{value}'" + case 'context': + response = f"{response} and\n Query Parameter: context set to '{value}'" + case _: + raise Exception(f"ERROR: unexpected attribute {result}, the attributes expected are " + f"{expected_parameters}, but received: {kwargs}") + + return response + @staticmethod def delete_subscription(kwargs) -> str: if 'id' in kwargs: diff --git a/doc/files/ContextInformation/Provision/054_01.json b/doc/files/ContextInformation/Provision/054_01.json index 023c5d1e..b1745150 100644 --- a/doc/files/ContextInformation/Provision/054_01.json +++ b/doc/files/ContextInformation/Provision/054_01.json @@ -30,7 +30,7 @@ "teardown": "Delete Initial Entity", "template": null, "then": "then {\n the SUT sends a valid Response for the operations:\n Replace Entity Selecting Content Type with Response Status Code set to 204 and\n Retrieve Entity by Id with Check Updated Entity and\n Query Parameter: 'updated_resource' set to 'entity_expectation_payload' and\n Query Parameter: 'response_body' set to 'response1.json()' and\n Query Parameter: 'ignored_keys' set to 'ignored_attributes' and\n Retrieve Entity by Id with Check Response Body containing an Attribute set to and\n Query Parameter: expected_attribute_name set to 'createdAt' and\n Query Parameter: response_body set to 'response1.json()' and\n Query Parameter: expected_attribute_value set to 'createdAt'\n}", - "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entity_id}'\n method set to 'PUT'\n Replace Entity Selecting Content Type and\n Query Parameter: entity_id set to '${entity_id}' and\n Query Parameter: entity_fragment set to '${entity}' and\n Query Parameter: content_type set to 'application/ld+json' and\n Query Parameter: context set to ''\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entity_id}'\n method set to 'PUT'\n Replace Entity Selecting Content Type and\n Query Parameter: entity_id set to '${entity_id}' and\n Query Parameter: entity_fragment set to '${entity}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", "http_verb": "PUT", "endpoint": "entities/{entity_id}" } diff --git a/doc/files/ContextInformation/Provision/054_02.json b/doc/files/ContextInformation/Provision/054_02.json index 30a65965..35e9446b 100644 --- a/doc/files/ContextInformation/Provision/054_02.json +++ b/doc/files/ContextInformation/Provision/054_02.json @@ -31,7 +31,7 @@ "teardown": "Delete Initial Entity", "template": "Replace an existing entity with a faulty ID", "then": "then {\n the SUT sends a valid Response for the operation:\n Replace Entity Selecting Content Type with 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/{entity_id}'\n method set to 'PUT'\n Replace Entity Selecting Content Type and\n Query Parameter: entity_id set to 'invalidUri' and\n Query Parameter: entity_fragment set to '${entity}' and\n Query Parameter: content_type set to 'application/ld+json' and\n Query Parameter: context set to ''\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entity_id}'\n method set to 'PUT'\n Replace Entity Selecting Content Type and\n Query Parameter: entity_id set to 'invalidUri' and\n Query Parameter: entity_fragment set to '${entity}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", "http_verb": "PUT", "endpoint": "entities/{entity_id}" }, @@ -49,7 +49,7 @@ "teardown": "Delete Initial Entity", "template": "Replace an existing entity with a faulty ID", "then": "then {\n the SUT sends a valid Response for the operation:\n Replace Entity Selecting Content Type with 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/{entity_id}'\n method set to 'PUT'\n Replace Entity Selecting Content Type and\n Query Parameter: entity_id set to '${EMPTY}' and\n Query Parameter: entity_fragment set to '${entity}' and\n Query Parameter: content_type set to 'application/ld+json' and\n Query Parameter: context set to ''\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entity_id}'\n method set to 'PUT'\n Replace Entity Selecting Content Type and\n Query Parameter: entity_id set to '${EMPTY}' and\n Query Parameter: entity_fragment set to '${entity}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", "http_verb": "PUT", "endpoint": "entities/{entity_id}" }, @@ -67,7 +67,7 @@ "teardown": "Delete Initial Entity", "template": "Replace an existing entity with a faulty ID", "then": "then {\n the SUT sends a valid Response for the operation:\n Replace Entity Selecting Content Type with 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/entities/{entity_id}'\n method set to 'PUT'\n Replace Entity Selecting Content Type and\n Query Parameter: entity_id set to 'urn:ngsi-ld:Building:Nonexistent' and\n Query Parameter: entity_fragment set to '${entity}' and\n Query Parameter: content_type set to 'application/ld+json' and\n Query Parameter: context set to ''\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entity_id}'\n method set to 'PUT'\n Replace Entity Selecting Content Type and\n Query Parameter: entity_id set to 'urn:ngsi-ld:Building:Nonexistent' and\n Query Parameter: entity_fragment set to '${entity}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", "http_verb": "PUT", "endpoint": "entities/{entity_id}" } diff --git a/doc/files/ContextInformation/Provision/055_01.json b/doc/files/ContextInformation/Provision/055_01.json new file mode 100644 index 00000000..bdbd9d4b --- /dev/null +++ b/doc/files/ContextInformation/Provision/055_01.json @@ -0,0 +1,60 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/EA/055_01", + "test_objective": "Check that one can replace an existing entity attribute and that its createdAt Temporal Property remains unchanged", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 5.6.19, 6.7.3.3", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "5.6.19", + "6.7.3.3" + ], + "pics_selection": "", + "keywords": [ + "Replace Entity Attribute", + "Setup 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": "055_01_01 Replace entity attribute", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/055_01_01", + "doc": "Check that one can replace an existing entity attribute and that its createdAt Temporal Property remains unchanged", + "tags": [ + "5_6_19", + "6_7_3_3", + "ea-replace", + "since_v1.6.1" + ], + "setup": "Setup Initial Entity", + "teardown": "Delete Initial Entity", + "template": "Replace Entity Attribute", + "then": "then {\n the SUT sends a valid Response for the operations:\n Replace Attribute Selecting Content Type with Response Status Code set to 204 and\n Retrieve Entity by Id with Check Updated Entity and\n Query Parameter: 'updated_resource' set to 'entity_expectation_payload' and\n Query Parameter: 'response_body' set to 'response1.json()' and\n Query Parameter: 'ignored_keys' set to 'ignored_attributes' and\n Retrieve Entity by Id with Response Body containing the key 'json_path_expr=['isParked']['createdAt']', with the value 'value_to_check=${createdAt}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entity_id}/attrs/{attr_id}'\n method set to 'PUT'\n Replace Attribute Selecting Content Type and\n Query Parameter: entity_id set to '${entity_id}' and\n Query Parameter: attr_id set to 'isParked' and\n Query Parameter: attribute_fragment set to '${attribute}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + }, + { + "name": "055_01_02 Replace entity attribute giving a new attribute type", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/055_01_02", + "doc": "Check that one can replace an existing entity attribute and that its createdAt Temporal Property remains unchanged", + "tags": [ + "5_6_19", + "6_7_3_3", + "ea-replace", + "since_v1.6.1" + ], + "setup": "Setup Initial Entity", + "teardown": "Delete Initial Entity", + "template": "Replace Entity Attribute", + "then": "then {\n the SUT sends a valid Response for the operations:\n Replace Attribute Selecting Content Type with Response Status Code set to 204 and\n Retrieve Entity by Id with Check Updated Entity and\n Query Parameter: 'updated_resource' set to 'entity_expectation_payload' and\n Query Parameter: 'response_body' set to 'response1.json()' and\n Query Parameter: 'ignored_keys' set to 'ignored_attributes' and\n Retrieve Entity by Id with Response Body containing the key 'json_path_expr=['isParked']['createdAt']', with the value 'value_to_check=${createdAt}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entity_id}/attrs/{attr_id}'\n method set to 'PUT'\n Replace Attribute Selecting Content Type and\n Query Parameter: entity_id set to '${entity_id}' and\n Query Parameter: attr_id set to 'isParked' and\n Query Parameter: attribute_fragment set to '${attribute}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute", + "robotfile": "055_01" +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Provision/055_02.json b/doc/files/ContextInformation/Provision/055_02.json new file mode 100644 index 00000000..4d1605c0 --- /dev/null +++ b/doc/files/ContextInformation/Provision/055_02.json @@ -0,0 +1,60 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/EA/055_02", + "test_objective": "Check that one can replace an existing multi-instance entity attribute and that its createdAt Temporal Property remains unchanged", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 5.6.19, 6.7.3.3", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "5.6.19", + "6.7.3.3" + ], + "pics_selection": "", + "keywords": [ + "Replace Multi Instance Entity Attribute", + "Setup 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": "055_02_01 Replace entity attribute giving no datasetId", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/055_02_01", + "doc": "Check that one can replace an existing multi-instance entity attribute and that its createdAt Temporal Property remains unchanged", + "tags": [ + "5_6_19", + "6_7_3_3", + "ea-replace", + "since_v1.6.1" + ], + "setup": "Setup Initial Entity", + "teardown": "Delete Initial Entity", + "template": "Replace Multi Instance Entity Attribute", + "then": "then {\n the SUT sends a valid Response for the operations:\n Replace Attribute Selecting Content Type with Response Status Code set to 204 and\n Retrieve Entity by Id with Check Updated Entity and\n Query Parameter: 'updated_resource' set to 'entity_expectation_payload' and\n Query Parameter: 'response_body' set to 'response1.json()' and\n Query Parameter: 'ignored_keys' set to 'ignored_attributes' and\n Retrieve Entity by Id with Response Body containing the key 'json_path_expr=['speed'][0]['createdAt']', with the value 'value_to_check=${createdAt}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entity_id}/attrs/{attr_id}'\n method set to 'PUT'\n Replace Attribute Selecting Content Type and\n Query Parameter: entity_id set to '${entity_id}' and\n Query Parameter: attr_id set to 'speed' and\n Query Parameter: attribute_fragment set to '${attribute}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + }, + { + "name": "055_02_02 Replace entity attribute giving a datasetId", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/055_02_02", + "doc": "Check that one can replace an existing multi-instance entity attribute and that its createdAt Temporal Property remains unchanged", + "tags": [ + "5_6_19", + "6_7_3_3", + "ea-replace", + "since_v1.6.1" + ], + "setup": "Setup Initial Entity", + "teardown": "Delete Initial Entity", + "template": "Replace Multi Instance Entity Attribute", + "then": "then {\n the SUT sends a valid Response for the operations:\n Replace Attribute Selecting Content Type with Response Status Code set to 204 and\n Retrieve Entity by Id with Check Updated Entity and\n Query Parameter: 'updated_resource' set to 'entity_expectation_payload' and\n Query Parameter: 'response_body' set to 'response1.json()' and\n Query Parameter: 'ignored_keys' set to 'ignored_attributes' and\n Retrieve Entity by Id with Response Body containing the key 'json_path_expr=['speed'][0]['createdAt']', with the value 'value_to_check=${createdAt}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entity_id}/attrs/{attr_id}'\n method set to 'PUT'\n Replace Attribute Selecting Content Type and\n Query Parameter: entity_id set to '${entity_id}' and\n Query Parameter: attr_id set to 'speed' and\n Query Parameter: attribute_fragment set to '${attribute}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute", + "robotfile": "055_02" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Provision.py b/doc/tests/test_ContextInformation_Provision.py index f4b3f9f4..c50e9bcb 100644 --- a/doc/tests/test_ContextInformation_Provision.py +++ b/doc/tests/test_ContextInformation_Provision.py @@ -672,6 +672,27 @@ class TestCIProvision(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_055_01(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_01.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/055_01.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_055_01.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_055_02(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_02.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/055_02.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_055_02.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_055_03(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/055_03.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_055_03.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_057_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpdateBatchOfEntities/005_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/057_01.json' diff --git a/resources/ApiUtils/ContextInformationProvision.resource b/resources/ApiUtils/ContextInformationProvision.resource index d513f815..e68f678e 100755 --- a/resources/ApiUtils/ContextInformationProvision.resource +++ b/resources/ApiUtils/ContextInformationProvision.resource @@ -298,3 +298,24 @@ Replace Entity Selecting Content Type ... expected_status=any Output ${response} Replace Entity Selecting Content Type RETURN ${response} + +Replace Attribute Selecting Content Type + [Arguments] + ... ${entity_id} + ... ${attr_id} + ... ${attribute_fragment} + ... ${content_type} + ... ${context}=${EMPTY} + &{headers}= Create Dictionary Content-Type=${content_type} + IF '${context}'!='' + Set To Dictionary + ... ${headers} + ... Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" + END + ${response}= PUT + ... url=${url}/${ENTITIES_ENDPOINT_PATH}${entity_id}/attrs/${attr_id} + ... headers=${headers} + ... json=${attribute_fragment} + ... expected_status=any + Output ${response} Replace Attribute Selecting Content Type + RETURN ${response} -- GitLab From 719dee37911989408a325ff9e5a8ab8bf4c051cd Mon Sep 17 00:00:00 2001 From: ranim-n Date: Tue, 26 Nov 2024 16:31:43 +0100 Subject: [PATCH 2/2] rename argument to generate documentation --- .../ReplaceEntityAttribute/055_03.robot | 4 +- .../ContextInformation/Provision/055_03.json | 117 ++++++++++++++++++ 2 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 doc/files/ContextInformation/Provision/055_03.json diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot index 2391ef88..31938756 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot @@ -37,12 +37,12 @@ ${entity_filename} vehicle-speed-multi-instances.jsonld *** Keywords *** Replace Entity Attribute With Faulty Data [Documentation] Check that the correct error type is returned when replacing an attribute with faulty data - [Arguments] ${entity_id} ${attr_id} ${attribute_replacement_filename} ${expected_status_code} + [Arguments] ${target_entity_id} ${attr_id} ${attribute_replacement_filename} ${expected_status_code} ${attribute}= Load Test Sample ... test_sample_file_path=entities/${attribute_replacement_filename} ... test_sample_id=${entity_id} ${response}= Replace Attribute Selecting Content Type - ... entity_id=${entity_id} + ... entity_id=${target_entity_id} ... attr_id=${attr_id} ... attribute_fragment=${attribute} ... content_type=${CONTENT_TYPE_JSON} diff --git a/doc/files/ContextInformation/Provision/055_03.json b/doc/files/ContextInformation/Provision/055_03.json new file mode 100644 index 00000000..2cf0b3d2 --- /dev/null +++ b/doc/files/ContextInformation/Provision/055_03.json @@ -0,0 +1,117 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/EA/055_03", + "test_objective": "Check that the correct error type is returned when replacing an attribute with faulty data", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 5.6.19, 6.7.3.3", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "5.6.19", + "6.7.3.3" + ], + "pics_selection": "", + "keywords": [ + "Replace Entity Attribute With Faulty Data", + "Setup 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": "055_03_01 Replace entity attribute giving an invalid entity ID", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/055_03_01", + "doc": "Check that the correct error type is returned when replacing an attribute with faulty data", + "tags": [ + "5_6_19", + "6_7_3_3", + "ea-replace", + "since_v1.6.1" + ], + "setup": "Setup Initial Entity", + "teardown": "Delete Initial Entity", + "template": "Replace Entity Attribute With Faulty Data", + "then": "then {\n the SUT sends a valid Response for the operation:\n Replace Attribute Selecting Content Type with 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/{entity_id}/attrs/{attr_id}'\n method set to 'PUT'\n Replace Attribute Selecting Content Type and\n Query Parameter: entity_id set to '${target_entity_id}' and\n Query Parameter: attr_id set to 'isParked' and\n Query Parameter: attribute_fragment set to '${attribute}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + }, + { + "name": "055_03_02 Replace entity attribute giving a nonexistent entity ID", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/055_03_02", + "doc": "Check that the correct error type is returned when replacing an attribute with faulty data", + "tags": [ + "5_6_19", + "6_7_3_3", + "ea-replace", + "since_v1.6.1" + ], + "setup": "Setup Initial Entity", + "teardown": "Delete Initial Entity", + "template": "Replace Entity Attribute With Faulty Data", + "then": "then {\n the SUT sends a valid Response for the operation:\n Replace Attribute Selecting Content Type with 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/entities/{entity_id}/attrs/{attr_id}'\n method set to 'PUT'\n Replace Attribute Selecting Content Type and\n Query Parameter: entity_id set to '${target_entity_id}' and\n Query Parameter: attr_id set to 'isParked' and\n Query Parameter: attribute_fragment set to '${attribute}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + }, + { + "name": "055_03_03 Replace entity attribute giving an invalid attribute name", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/055_03_03", + "doc": "Check that the correct error type is returned when replacing an attribute with faulty data", + "tags": [ + "5_6_19", + "6_7_3_3", + "ea-replace", + "since_v1.6.1" + ], + "setup": "Setup Initial Entity", + "teardown": "Delete Initial Entity", + "template": "Replace Entity Attribute With Faulty Data", + "then": "then {\n the SUT sends a valid Response for the operation:\n Replace Attribute Selecting Content Type with 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/{entity_id}/attrs/{attr_id}'\n method set to 'PUT'\n Replace Attribute Selecting Content Type and\n Query Parameter: entity_id set to '${target_entity_id}' and\n Query Parameter: attr_id set to '@invalid' and\n Query Parameter: attribute_fragment set to '${attribute}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + }, + { + "name": "055_03_04 Replace entity attribute giving a nonexistent attribute name", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/055_03_04", + "doc": "Check that the correct error type is returned when replacing an attribute with faulty data", + "tags": [ + "5_6_19", + "6_7_3_3", + "ea-replace", + "since_v1.6.1" + ], + "setup": "Setup Initial Entity", + "teardown": "Delete Initial Entity", + "template": "Replace Entity Attribute With Faulty Data", + "then": "then {\n the SUT sends a valid Response for the operation:\n Replace Attribute Selecting Content Type with 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/entities/{entity_id}/attrs/{attr_id}'\n method set to 'PUT'\n Replace Attribute Selecting Content Type and\n Query Parameter: entity_id set to '${target_entity_id}' and\n Query Parameter: attr_id set to 'brandName' and\n Query Parameter: attribute_fragment set to '${attribute}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + }, + { + "name": "055_03_05 Replace entity attribute giving a scope attribute", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/055_03_05", + "doc": "Check that the correct error type is returned when replacing an attribute with faulty data", + "tags": [ + "5_6_19", + "6_7_3_3", + "ea-replace", + "since_v1.6.1" + ], + "setup": "Setup Initial Entity", + "teardown": "Delete Initial Entity", + "template": "Replace Entity Attribute With Faulty Data", + "then": "then {\n the SUT sends a valid Response for the operation:\n Replace Attribute Selecting Content Type with 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/{entity_id}/attrs/{attr_id}'\n method set to 'PUT'\n Replace Attribute Selecting Content Type and\n Query Parameter: entity_id set to '${target_entity_id}' and\n Query Parameter: attr_id set to 'scope' and\n Query Parameter: attribute_fragment set to '${attribute}' and\n Query Parameter: content_type set to 'application/json' and\n Query Parameter: context set to 'https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld'\n}", + "http_verb": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + } + ], + "permutations": [ + "then", + "when" + ], + "robotpath": "ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute", + "robotfile": "055_03" +} \ No newline at end of file -- GitLab