Commit b32297f6 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat: append type in update attributes operation

parent eec2faf1
Loading
Loading
Loading
Loading
+60 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Documentation       Check that you can update the types on an entity

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Create Initial Entity
Test Teardown       Delete Initial Entity
Test Template       Append Types to an Entity


*** Variables ***
${vehicle_id_prefix}=       urn:ngsi-ld:Vehicle:
${entity_filename}=         building-minimal-sample.json


*** Test Cases ***    FRAGMENT_FILENAME    EXPECTATION_FILENAME
011_06_01 AppendOneType
    type-vehicle-fragment.json    building-minimal-with-two-types.json
011_06_02 AppendTwoTypes
    types-vehicle-car-fragment.json    building-minimal-with-three-types.json
011_06_03 AppendExistingType
    type-building-fragment.json    building-minimal-compacted-expectation.json
011_06_04 AppendOneTypeAndOneExisting
    type-vehicle-building-fragment.json    building-minimal-with-two-types.json


*** Keywords ***
Append Types to an Entity
    [Documentation]    Check that type is appended if it is not yet in the target entity
    [Tags]    ea-append    5_6_2    4_16    since_v1.5.1
    [Arguments]    ${type_fragment_filename}    ${expectation_filename}

    ${response}=    Update Entity Attributes
    ...    ${entity_id}
    ...    ${type_fragment_filename}
    ...    ${CONTENT_TYPE_LD_JSON}

    Check Response Status Code    204    ${response.status_code}
    ${response}=    Retrieve Entity by Id
    ...    ${entity_id}
    ...    accept=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response.json()}

Create Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Test Variable    ${entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${entity_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_JSON}
    ...    ${ngsild_test_suite_context}
    Check Response Status Code    201    ${response.status_code}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
+4 −0
Original line number Original line Diff line number Diff line
{
    "id": "urn:ngsi-ld:Building:randomUUID",
    "type": ["Building", "Vehicle", "Car"]
}
 No newline at end of file
+4 −0
Original line number Original line Diff line number Diff line
{
    "id": "urn:ngsi-ld:Building:randomUUID",
    "type": ["Building", "Vehicle"]
}
 No newline at end of file
+6 −0
Original line number Original line Diff line number Diff line
{
    "type": "Building",
    "@context": [
      "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld"
    ]
}
 No newline at end of file
+6 −0
Original line number Original line Diff line number Diff line
{
    "type": ["Building", "Vehicle"],
    "@context": [
      "https://easy-global-market.github.io/ngsild-api-data-models/ngsildTestSuite/ngsildTestSuiteV1.8-compound.jsonld"
    ]
}
 No newline at end of file
Loading