From cc2a95eaea92317a64f80f95568cb97c3e4fc115 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Wed, 20 Jan 2021 17:38:17 +0000 Subject: [PATCH 1/2] added delete entity attributes suite --- .../Provision/EntityAttributes/010.robot | 33 ++++++++++++++++ .../Provision/EntityAttributes/011.robot | 36 ++++++++++++++++++ .../Provision/EntityAttributes/012.robot | 38 +++++++++++++++++++ resources/ApiUtils.resource | 11 ++++++ 4 files changed, 118 insertions(+) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/011.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/012.robot diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010.robot new file mode 100644 index 00000000..83c959c5 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/010.robot @@ -0,0 +1,33 @@ +*** Settings *** +Documentation Check that you can delete an attribute from an entity +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Append Attributes + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${status_code}= 204 +${filename}= vehicle-two-datasetid-attributes-sample.jsonld +${attribute_id}= speed + +*** Test Cases *** DATASETID DELETEALL +010_01_delete an attribute with the id ${EMPTY} ${EMPTY} +010_02_delete an attribute with the datasetId urn:ngsi-ld:Property:gpsBxyz123-speed ${EMPTY} +010_03_delete all target attribute instances with a datasetId urn:ngsi-ld:Property:gpsBxyz123-speed True + +*** Keywords *** +Append Attributes + [Arguments] ${datasetId} ${deleteAll} + [Documentation] Check that you can delete an attribute from an entity + [Tags] mandatory failing + + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Delete Entity Attributes ${entity_id} ${attribute_id} ${CONTENT_TYPE_LD_JSON} ${datasetId} ${deleteAll} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/011.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/011.robot new file mode 100644 index 00000000..ebdd033b --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/011.robot @@ -0,0 +1,36 @@ +*** Settings *** +Documentation Check that you cannot delete an attribute from an entity with invalid/missing ids +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Test Template Append Attributes + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${status_code}= 400 +${filename}= vehicle-two-datasetid-attributes-sample.jsonld + +*** Test Cases *** ENTITY_ID ATTRIBUTE_ID +011_01_delete an attribute if the Entity Id is not present ${EMPTY} speed +011_02_delete an attribute if the Entity Id is not a valid URI thisIsAnInvalidURI speed +011_03_delete an attribute if the Attribute Name is not present ${valid_entity_id} ${EMPTY} + +*** Keywords *** +Append Attributes + [Arguments] ${entity_id} ${attribute_id} + [Documentation] Check that you cannot delete an attribute from an entity with invalid/missing ids + [Tags] mandatory failing + + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Delete Entity Attributes ${entity_id} ${attribute_id} ${CONTENT_TYPE_LD_JSON} ${EMPTY} ${EMPTY} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} + +Setup Initial Entities + ${valid_entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + Set Suite Variable ${valid_entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/012.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/012.robot new file mode 100644 index 00000000..6db51b62 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/012.robot @@ -0,0 +1,38 @@ +*** Settings *** +Documentation Check that you cannot delete an attribute from an entity with invalid/missing ids +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Entities +Test Template Append Attributes + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${status_code}= 400 +${filename}= vehicle-two-datasetid-attributes-sample.jsonld + +*** Test Cases *** ENTITY_ID ATTRIBUTE_ID DATASETID +012_01_delete an attribute when the Entity Id is not known to the system ${not_found_entity_id} speed urn:ngsi-ld:Property:gpsBxyz123-speed +012_02_delete an attribute when the Entity does not contain the target attribute id ${valid_entity_id} notFound ${EMPTY} +012_03_delete an attribute when the Entity does not contain the target attribute with same datasetId ${valid_entity_id} speed urn:ngsi-ld:Property:notFound + +*** Keywords *** +Append Attributes + [Arguments] ${entity_id} ${attribute_id} ${datasetId} + [Documentation] Check that you cannot delete an attribute from an entity with invalid/missing ids + [Tags] mandatory failing + + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Delete Entity Attributes ${entity_id} ${attribute_id} ${CONTENT_TYPE_LD_JSON} ${datasetId} ${EMPTY} + Check Response Status Code ${status_code} ${response['status']} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} + +Setup Initial Entities + ${valid_entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + Set Suite Variable ${valid_entity_id} + ${not_found_entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + Set Suite Variable ${not_found_entity_id} \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index e32f96d6..0d06d1e8 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -156,6 +156,17 @@ Update Entity Attributes Output response [return] ${response} +Delete Entity Attributes + [Arguments] ${entityId} ${attributeId} ${content_type} ${datasetId} ${deleteAll} + &{headers}= Create Dictionary Content-Type=${content_type} + &{params}= Create Dictionary + Run Keyword If '${datasetId}'!='' Set To Dictionary ${params} datasetId=${datasetId} + Run Keyword If '${deleteAll}'!='' Set To Dictionary ${params} deletelAll=${deleteAll} + ${response}= DELETE ${ENTITIES_ENDPOINT_PATH}${entityId}/attrs/${attributeId} headers=${headers} parameter=${params} + Output request + Output response + [return] ${response} + Partial Update Entity Attributes [Arguments] ${entityId} ${attributeId} ${fragment_filename} ${content_type} &{headers}= Create Dictionary Content-Type=${content_type} -- GitLab From 2c73170c07cc228d6c04176d08687803eceec6a7 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Wed, 20 Jan 2021 17:40:10 +0000 Subject: [PATCH 2/2] status code change --- .../ContextInformation/Provision/EntityAttributes/012.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/012.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/012.robot index 6db51b62..1b64141a 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/012.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/012.robot @@ -9,7 +9,7 @@ Test Template Append Attributes *** Variable *** ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: -${status_code}= 400 +${status_code}= 404 ${filename}= vehicle-two-datasetid-attributes-sample.jsonld *** Test Cases *** ENTITY_ID ATTRIBUTE_ID DATASETID -- GitLab