Commit 6687f5ef authored by Patricia dos Santos Oliveira's avatar Patricia dos Santos Oliveira
Browse files

Merge branch 'feature/delete-entity-attributes' into 'develop'

Feature/delete entity attributes

See merge request !19
parents f2f79261 2c73170c
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
*** 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
+36 −0
Original line number Diff line number Diff line
*** 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
+38 −0
Original line number Diff line number Diff line
*** 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
+11 −0
Original line number Diff line number Diff line
@@ -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}