Commit e42ab048 authored by lopesg's avatar lopesg
Browse files

added update entity tests

parent f5099cb1
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -10,10 +10,10 @@ Test Template Append Attributes
${vehicle_id_prefix}=  urn:ngsi-ld:Vehicle:

*** Test Cases ***                    STATUS_CODE      OVERWRITE           FILENAME                                           FRAGMENT_FILENAME                                         EXPECTATION_FILENAME
001_01_Append entity attributes       204              ${EMPTY}            vehicle-datasetid-attributes-sample.jsonld         vehicle-fragment-datasetid-sample-01-02.jsonld        vehicle-attributes-sample-append-expectation-01.jsonld
001_02_Append entity attributes       207              noOverwrite         vehicle-datasetid-attributes-sample.jsonld         vehicle-fragment-datasetid-sample-01-02.jsonld        vehicle-attributes-sample-append-expectation-02.jsonld
001_03_Append entity attributes       204              ${EMPTY}            vehicle-datasetid-attributes-sample.jsonld         vehicle-fragment-datasetid-sample-03-04.jsonld        vehicle-attributes-sample-append-expectation-03-04.jsonld
001_04_Append entity attributes       204              noOverwrite         vehicle-datasetid-attributes-sample.jsonld         vehicle-fragment-datasetid-sample-03-04.jsonld        vehicle-attributes-sample-append-expectation-03-04.jsonld
001_01_Append entity attributes       204              ${EMPTY}            vehicle-datasetid-attributes-sample.jsonld         vehicle-fragment-same-datasetid-sample.jsonld             vehicle-attributes-sample-append-expectation-01.jsonld
001_02_Append entity attributes       207              noOverwrite         vehicle-datasetid-attributes-sample.jsonld         vehicle-fragment-same-datasetid-sample.jsonld             vehicle-attributes-sample-append-expectation-02.jsonld
001_03_Append entity attributes       204              ${EMPTY}            vehicle-datasetid-attributes-sample.jsonld         vehicle-fragment-different-datasetid-sample.jsonld        vehicle-attributes-sample-append-expectation-03-04.jsonld
001_04_Append entity attributes       204              noOverwrite         vehicle-datasetid-attributes-sample.jsonld         vehicle-fragment-different-datasetid-sample.jsonld        vehicle-attributes-sample-append-expectation-03-04.jsonld

*** Keywords ***
Append Attributes
@@ -27,6 +27,6 @@ Append Attributes

    ${response}=    Append Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}    ${overwrite}
    Check Response Status Code  ${status_code}    ${response['status']}
    Check Response Body Containing Entity element    ${expectation_filename}    ${entity_id}    ${response['body']}
    Check Response Body Content    ${expectation_filename}    ${response['body']}

    [Teardown]  Delete Entity by Id Returning Response   ${entity_id}
 No newline at end of file
+32 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can update entity attributes
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Test Template  Update Attributes

*** Variable ***
${vehicle_id_prefix}=  urn:ngsi-ld:Vehicle:

*** Test Cases ***                                                                STATUS_CODE               FILENAME                                               FRAGMENT_FILENAME                                        EXPECTATION_FILENAME
004_01_Check that you can update existing attributes with no datasetId            204                       vehicle-two-datasetid-attributes-sample.jsonld         vehicle-two-datasetid-attributes-sample-01.jsonld        vehicle-two-datasetid-attributes-sample-expectation-01.jsonld
004_02_Check that you can update existing attributes with the datasetId           204                       vehicle-two-datasetid-attributes-sample.jsonld         vehicle-two-datasetid-attributes-sample-02.jsonld        vehicle-two-datasetid-attributes-sample-expectation-01.jsonld
004_03_Check that you can update only some attributes while others failed         207                       vehicle-two-datasetid-attributes-sample.jsonld         vehicle-two-datasetid-attributes-sample-03.jsonld        vehicle-two-datasetid-attributes-sample-expectation-03.jsonld
004_04_Check that you cannot change the type of the attribute                     204                       vehicle-two-datasetid-attributes-sample.jsonld         vehicle-two-datasetid-attributes-sample-04.jsonld        vehicle-two-datasetid-attributes-sample-expectation-04.jsonld

*** Keywords ***
Update Attributes
    [Arguments]  ${status_code}    ${filename}    ${fragment_filename}    ${expectation_filename}
    [Documentation]  Check that you can update entity attributes
    [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}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  ${status_code}    ${response['status']}
    Check Response Body Content    ${expectation_filename}    ${response['body']}

    [Teardown]  Delete Entity by Id Returning Response   ${entity_id}
 No newline at end of file
+33 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot update entity attributes with invalid/missing id or invalid request body
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Test Template  Update Attributes

*** Variable ***
${vehicle_id_prefix}=  urn:ngsi-ld:Vehicle:
${filename}=  vehicle-two-datasetid-attributes-sample.jsonld
${fragment_filename}=  vehicle-two-datasetid-attributes-sample-01.jsonld

*** Test Cases ***                                                             STATUS_CODE     ENTITY_INVALID_ID      
005_01_Update an attribute if the Entity Id is not present                     400             ${EMPTY}               
005_02_Update an attribute if the Entity Id is not a valid URI                 400             thisisaninvaliduri

*** Keywords ***
Update Attributes
    [Arguments]  ${status_code}    ${entity_invalid_id}
    [Documentation]  Check that you cannot update entity attributes with invalid/missing id or invalid request body
    [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}=    Update Entity Attributes    ${entity_invalid_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  ${status_code}    ${response['status']}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}

    [Teardown]  Delete Entity by Id Returning Response   ${entity_id}
 No newline at end of file
+26 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot update an attribute if the entity fragment is invalid
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${vehicle_id_prefix}=  urn:ngsi-ld:Vehicle:
${filename}=  vehicle-datasetid-attributes-sample.jsonld
${fragment_filename}=  invalid-vehicle-fragment-datasetid-sample.jsonld

*** Test Cases ***              
Update entity attributes with invalid entity fragments
    [Documentation]  Check that you cannot update an attribute if the entity fragment is invalid
    [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}=    Update Entity Attributes Using Session    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}    ${EMPTY}
    Check Response Status Code  400    ${response}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}

    [Teardown]  Delete Entity by Id Returning Response   ${entity_id}
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot update entity attributes if the entity id or attributes are not known to the system
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${vehicle_id_prefix}=  urn:ngsi-ld:Vehicle:
${fragment_filename}=  vehicle-two-datasetid-attributes-sample-01.jsonld

*** Test Cases ***  
003_Update entity attributes when the entity id is not known to the system
    [Documentation]  Check that you cannot update entity attributes if the entity id or attributes are not known to the system
    [Tags]  mandatory  failing

    ${entity_id}=     Generate Random Entity Id    ${vehicle_id_prefix}
    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  404    ${response['status']}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_RESOURCE_NOT_FOUND}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}

*** Keywords ***
    [Teardown]  Delete Entity by Id Returning Response   ${entity_id}
 No newline at end of file
Loading