Commit 792a45ef authored by root's avatar root
Browse files

added append attributes suites

parent f07c2a32
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can append entity attributes
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:

*** 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

*** Keywords ***
Append Attributes
    [Arguments]  ${status_code}    ${overwrite}    ${filename}    ${fragment_filename}    ${expectation_filename}
    [Documentation]  Check that you can append 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}=    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']}

    [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 append 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  Append Attributes

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

*** Test Cases ***                                                             STATUS_CODE     ENTITY_INVALID_ID      
002_01_Append entity attributes if the entity Id is not present                400             ${EMPTY}               
002_02_Append entity attributes if the Entity Id is not a valid URI            400             thisisaninvaliduri

*** Keywords ***
Append Attributes
    [Arguments]  ${status_code}    ${entity_invalid_id}
    [Documentation]  Check that you cannot append 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}=    Append Entity Attributes    ${entity_invalid_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}    ${EMPTY}
    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 append entity attributes with invalid entity fragments
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 ***              
Append entity attributes with invalid entity fragments
    [Documentation]  Check that you cannot append entity attributes with invalid entity fragments
    [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}=    Append Entity Attributes Using Session    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}    ${EMPTY}
    Check Response Status Code  400    ${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
+39 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "type": "Vehicle",
    "brandName": {
        "type": "Property",
        "value": "BMW"
    },
    "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": 56,
        "source": {
            "type": "Property",
            "value": "Speedometer"
        },
        "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" 
    },
    {
        "type": "Property",
        "value": 54.5,
        "source": {
            "type": "Property",
            "value": "GPS"
        },
        "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed"
    }], 
    "@context": [
        "https://fiware.github.io/data-models/context.jsonld",
        "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
    ]
}
 No newline at end of file
+30 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "type": "Vehicle",
    "brandName": {
        "type": "Property",
        "value": "Mercedes"
    },
    "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": 56,
        "source": {
            "type": "Property",
            "value": "Speedometer"
        },
        "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" 
    },
    "@context": [
        "https://fiware.github.io/data-models/context.jsonld",
        "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
    ]
}
 No newline at end of file
Loading