Commit b9202436 authored by kzangeli's avatar kzangeli
Browse files

feat(entity-attributes): add TCs for Set Attribute Value (063_01 value, 063_02...

feat(entity-attributes): add TCs for Set Attribute Value (063_01 value, 063_02 observedAt, 063_03 errors)
Same conventions as !327: since_ts104_v1.1.1 (TS 104-175 clause 10.2.6 has no ETSI GS CIM 009 counterpart),
the 063_03 template argument named as its column (${entity_id}, suite variable ${building_id}), the
ProblemDetails title checked.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent c4483a07
Loading
Loading
Loading
Loading
+45 −0
Changes for TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/SetAttributeValue/063_01.robot: 45 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can set the value of an Attribute of an Entity with a value only Attribute fragment, the type of the Attribute kept

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

Test Setup          Create Initial Entity
Test Teardown       Delete Initial Entity


*** Variables ***
${filename}=    building-simple-attributes.jsonld


*** Test Cases ***
063_01_01 Set The Value Of A Property
    [Documentation]    Check that the value is replaced and the Attribute is still a Property
    [Tags]    since_ts104_v1.1.1    ea-set-value    core_10_2_6    http_7_6_3_2
    ${response}=    Set Entity Attribute Value
    ...    entity_id=${entity_id}
    ...    attr_id=name
    ...    value="Notre-Dame"
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}
    ${response}=    Retrieve Entity Attribute
    ...    id=${entity_id}
    ...    attr_id=name
    ...    context=${ngsild_test_suite_context}
    Check Response Body Content    attribute-fragment-name-set.json    ${response.json()}


*** Keywords ***
Create Initial Entity
    ${entity_id}=    Generate Random Building Entity Id
    ${response}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    Set Test Variable    ${entity_id}

Delete Initial Entity
    Delete Entity    ${entity_id}
+65 −0
Changes for TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/SetAttributeValue/063_02.robot: 65 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that setting the value of an Attribute that has an observedAt sub-Attribute updates the observedAt to the observedAt parameter, or removes it when the parameter is not given

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

Test Setup          Create Initial Entity
Test Teardown       Delete Initial Entity


*** Variables ***
${filename}=    building-simple-attributes.jsonld


*** Test Cases ***
063_02_01 Set The Value With An observedAt Parameter
    [Documentation]    Check that the observedAt sub-Attribute takes the value of the observedAt parameter
    [Tags]    since_ts104_v1.1.1    ea-set-value    core_10_2_6    http_7_6_3_2
    ${response}=    Set Entity Attribute Value
    ...    entity_id=${entity_id}
    ...    attr_id=airQualityLevel
    ...    value=6
    ...    context=${ngsild_test_suite_context}
    ...    observedAt=2024-01-01T00:00:00Z
    Check Response Status Code    204    ${response.status_code}
    ${response}=    Retrieve Entity Attribute
    ...    id=${entity_id}
    ...    attr_id=airQualityLevel
    ...    context=${ngsild_test_suite_context}
    Check JSON Value In Response Body    ['value']    6    ${response.json()}
    Check JSON Value In Response Body    ['type']    Property    ${response.json()}
    Check JSON Value In Response Body    ['observedAt']    2024-01-01T00:00:00Z    ${response.json()}

063_02_02 Set The Value Without An observedAt Parameter
    [Documentation]    Check that the observedAt sub-Attribute is removed when no observedAt parameter is given
    [Tags]    since_ts104_v1.1.1    ea-set-value    core_10_2_6    http_7_6_3_2
    ${response}=    Set Entity Attribute Value
    ...    entity_id=${entity_id}
    ...    attr_id=airQualityLevel
    ...    value=5
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}
    ${response}=    Retrieve Entity Attribute
    ...    id=${entity_id}
    ...    attr_id=airQualityLevel
    ...    context=${ngsild_test_suite_context}
    Check JSON Value In Response Body    ['value']    5    ${response.json()}
    Check JSON Value In Response Body    ['type']    Property    ${response.json()}
    Check JSON Value Not In Response Body    $.observedAt    ${response.json()}


*** Keywords ***
Create Initial Entity
    ${entity_id}=    Generate Random Building Entity Id
    ${response}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    Set Test Variable    ${entity_id}

Delete Initial Entity
    Delete Entity    ${entity_id}
+63 −0
Changes for TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/SetAttributeValue/063_03.robot: 63 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot set the value of an Attribute: if the Entity id is not a valid URI, the Attribute is scope (400 BadRequestData), the body is not valid JSON or is null (400 InvalidRequest), or the Entity or the Attribute is not known (404 ResourceNotFound)

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

Suite Setup         Create Initial Entity
Suite Teardown      Delete Initial Entity
Test Template       Set The Value Of An Attribute With An Error


*** Variables ***
${filename}=    building-simple-attributes.jsonld


*** Test Cases ***    ENTITY_ID    ATTRIBUTE    VALUE    EXPECTED_STATUS_CODE    PROBLEM_TYPE
063_03_01 Set The Value If The Entity Id Is Not A Valid URI
    [Tags]    since_ts104_v1.1.1    ea-set-value    core_10_2_6    http_7_6_3_2
    thisisaninvaliduri    name    "Notre-Dame"    400    ${ERROR_TYPE_BAD_REQUEST_DATA}
063_03_02 Set The Value Of Scope
    [Tags]    since_ts104_v1.1.1    ea-set-value    core_10_2_6    http_7_6_3_2
    ${building_id}    scope    "/Madrid"    400    ${ERROR_TYPE_BAD_REQUEST_DATA}
063_03_03 Set The Value With A Body That Is Not Valid JSON
    [Tags]    since_ts104_v1.1.1    ea-set-value    core_10_2_6    http_7_6_3_2
    ${building_id}    name    {"oops    400    ${ERROR_TYPE_INVALID_REQUEST}
063_03_04 Set The Value To Null
    [Tags]    since_ts104_v1.1.1    ea-set-value    core_10_2_6    http_7_6_3_2
    ${building_id}    name    null    400    ${ERROR_TYPE_INVALID_REQUEST}
063_03_05 Set The Value If The Entity Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-set-value    core_10_2_6    http_7_6_3_2
    urn:ngsi-ld:Building:unknown063    name    "Notre-Dame"    404    ${ERROR_TYPE_RESOURCE_NOT_FOUND}
063_03_06 Set The Value If The Attribute Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-set-value    core_10_2_6    http_7_6_3_2
    ${building_id}    unknownAttribute    "Notre-Dame"    404    ${ERROR_TYPE_RESOURCE_NOT_FOUND}


*** Keywords ***
Create Initial Entity
    ${building_id}=    Generate Random Building Entity Id
    ${response}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${building_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    Set Suite Variable    ${building_id}

Delete Initial Entity
    Delete Entity    ${building_id}

Set The Value Of An Attribute With An Error
    [Documentation]    Check that one cannot set the value of an Attribute with an invalid request or of an unknown Entity or Attribute
    [Arguments]    ${entity_id}    ${attribute}    ${value}    ${expected_status_code}    ${problem_type}

    ${response}=    Set Entity Attribute Value
    ...    entity_id=${entity_id}
    ...    attr_id=${attribute}
    ...    value=${value}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    ${expected_status_code}    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${problem_type}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}
+4 −0
Changes for data/entities/expectations/attribute-fragment-name-set.json: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
    "type": "Property",
    "value": "Notre-Dame"
}
+1 −0
Changes for doc/analysis/generaterobotdata.py: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ class GenerateRobotData:
            'EntityAttributes/UpdateEntityAttributes': 'EA',
            'EntityAttributes/PartialAttributeUpdate': 'EA',
            'EntityAttributes/ReplaceEntityAttribute': 'EA',
            'EntityAttributes/SetAttributeValue': 'EA',
            'EntityAttributes/DeleteEntityAttribute': 'EA',
            'BatchEntities/CreateBatchOfEntities': 'BE',
            'BatchEntities/UpsertBatchOfEntities': 'BE',
Loading