diff --git a/README.md b/README.md index efc1acfb097a60d880c6f98c9d42f8fbf97c4a27..14439ebc5cb7445b7b937c7088548f41b873f541 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 af9788874f63ade46477a1561c2997c5c7742349..dffa254a0dfd0728aec88d532d5262a618d86420 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 8bd6905ca329f0d1bbb4fffa1391d26077f17eb9..f60447e8a01c9490c6c82c411d5ee7efdd403a55 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 0000000000000000000000000000000000000000..e438615e7fdf40a2bca6fbfcb52686a41312279f --- /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 0000000000000000000000000000000000000000..ac80245a6e28cf82163246a4bbdd5de13ca22c01 --- /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 0000000000000000000000000000000000000000..31938756d7a4d424f3ad4a5d16e95c0570b89d5d --- /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] ${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=${target_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 9cac6ee659d65b242b71b9014626962543c8fd45..e461c069207f5769d5e4083dc687b4482f0ae2cd 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 0000000000000000000000000000000000000000..54390ba46c895d55f26e184b264f069453f272ac --- /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 0000000000000000000000000000000000000000..ecba2fd0b2ece725efe4b2e7022014f1007fb17d --- /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 0000000000000000000000000000000000000000..0df540cfb994764a1d12511c75baa39ab7074427 --- /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 0000000000000000000000000000000000000000..60a6ac486bd20ed17ebb75e2afcb93167eee52a4 --- /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 0000000000000000000000000000000000000000..f36701b122df65c66fede19636451e03c087a4ad --- /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 0000000000000000000000000000000000000000..c9dff961364d3251a1356fb8914ab9255c7013fe --- /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 0000000000000000000000000000000000000000..94cad926f457d3759dab6adf141229adb436c204 --- /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 0000000000000000000000000000000000000000..f28e9b5bd47e45f726559fb5d5e75acbc83983e8 --- /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 0000000000000000000000000000000000000000..db89c4e9cb02f77a79bf0f2de83131daf1e3423e --- /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 0000000000000000000000000000000000000000..3f556e3db760850e0e52f94904d5612ae7b71eea --- /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 d90b38ce0b7ba34fe5ef36407e57ef1e31a0e366..ff408f6107a59d139797687c83edeb0c75c3ef72 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 8a98b2f2622432cdcf20a980a6d459715ae9a13d..aec2292de8ee04199996cd21d0b011b7c62cf80a 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 023c5d1e5cfacdd41a0989afb8f84215966b76e9..b17451501ab81ec5e312e0c120518bec36d3e13c 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 30a65965dbeb6f60123a2fbf4aa19b7b2cea97b7..35e9446bf6ec1382227ad04925d7956e7cad9998 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 0000000000000000000000000000000000000000..bdbd9d4b684f2bf6c25dac6e02221bc735932ae5 --- /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 0000000000000000000000000000000000000000..4d1605c039e58b9abc5187b3611b23d0ce588142 --- /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/files/ContextInformation/Provision/055_03.json b/doc/files/ContextInformation/Provision/055_03.json new file mode 100644 index 0000000000000000000000000000000000000000..2cf0b3d24e7b0ead39ec88dc6688d20e5dce3b92 --- /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 diff --git a/doc/tests/test_ContextInformation_Provision.py b/doc/tests/test_ContextInformation_Provision.py index f4b3f9f400ab9726a24e324ffb2e0c1f79e7542e..c50e9bcb21ba62845ec3a6d517c1e6319d431921 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 d513f815ba2abd4fa0b43b6b2facbfbe71c1b864..e68f678eb966c03bdcdf2dc38e988975d76356f0 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}