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 0000000000000000000000000000000000000000..83c959c5217aaa6cd9f6c5d2297c484e4a922a94 --- /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 0000000000000000000000000000000000000000..ebdd033bb75134352d75d30ee85775e2c597a041 --- /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 0000000000000000000000000000000000000000..1b64141a3bd9194383ebc4dcf2688e46da665253 --- /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}= 404 +${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 e32f96d6ecf5bf4dae9589cee352a31271659c33..0d06d1e89591b36e532c8946edfb0cfd99d7e19c 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}