Commit c10da8c3 authored by kzangeli's avatar kzangeli
Browse files

feat(entity-attributes): add TCs for Retrieve Attribute Value (062_02 value only, 062_04 errors)

GET /entities/{entityId}/attrs/{attrId}/value (TS 104-176 7.6.3.1, TS 104-175 10.4.4), next to the Retrieve
Attribute TCs of !327 in Consumption/EntityAttributes/RetrieveAttributeValue, with the same conventions:
since_ts104_v1.1.1, the template argument named as its column (${entity_id}, suite variable ${building_id}),
the ProblemDetails title checked in 062_04 and the Content-Type in 062_02, no accept argument.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 604eafaf
Loading
Loading
Loading
Loading
+49 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/062_02.robot: 49 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve the value of an Attribute of an Entity: the response body is the value only Attribute fragment

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

Suite Setup         Create Initial Entity
Suite Teardown      Delete Initial Entity
Test Template       Retrieve The Value Of An Attribute Of An Entity


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


*** Test Cases ***    ATTRIBUTE    EXPECTED_VALUE
062_02_01 Retrieve The Value Of A String Property
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    core_10_4_4    http_7_6_3_1
    name    Eiffel Tower
062_02_02 Retrieve The Value Of A Number Property
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    core_10_4_4    http_7_6_3_1
    airQualityLevel    4


*** 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 Suite Variable    ${entity_id}

Delete Initial Entity
    Delete Entity    ${entity_id}

Retrieve The Value Of An Attribute Of An Entity
    [Documentation]    Check that one can retrieve the value of an Attribute of an Entity
    [Arguments]    ${attribute}    ${expected_value}

    ${response}=    Retrieve Entity Attribute Value
    ...    id=${entity_id}
    ...    attr_id=${attribute}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}
    Check Response Headers Containing Content-Type set to    ${CONTENT_TYPE_JSON}    ${response.headers}
    Check Response Body Containing Attribute Value set to    ${expected_value}    ${response}
+54 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/062_04.robot: 54 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot retrieve the value of an Attribute of an Entity if the Entity id is not a valid URI (400), or if the Entity or the Attribute is not known (404)

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

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


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


*** Test Cases ***    ENTITY_ID    ATTRIBUTE    EXPECTED_STATUS_CODE    PROBLEM_TYPE
062_04_01 Retrieve The Value Of An Attribute If The Entity Id Is Not A Valid URI
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    core_10_4_4    http_7_6_3_1
    thisisaninvaliduri    name    400    ${ERROR_TYPE_BAD_REQUEST_DATA}
062_04_02 Retrieve The Value Of An Attribute If The Entity Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    core_10_4_4    http_7_6_3_1
    urn:ngsi-ld:Building:unknown062    name    404    ${ERROR_TYPE_RESOURCE_NOT_FOUND}
062_04_03 Retrieve The Value Of An Attribute If The Attribute Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    core_10_4_4    http_7_6_3_1
    ${building_id}    unknownAttribute    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}

Retrieve The Value Of An Attribute With An Error
    [Documentation]    Check that one cannot retrieve the value of an Attribute of an Entity that is not valid or not known
    [Arguments]    ${entity_id}    ${attribute}    ${expected_status_code}    ${problem_type}

    ${response}=    Retrieve Entity Attribute Value
    ...    id=${entity_id}
    ...    attr_id=${attribute}
    ...    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()}
+13 −0
Changes for doc/analysis/checks.py: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ class Checks:
                Checks.check_response_body_containing_context_source_registration_element,
            'Check Response Body Containing EntityTypeList element':
                Checks.check_response_body_containing_entitytypelist_element,
            'Check Response Body Containing Attribute Value set to':
                Checks.check_response_body_containing_attribute_value_set_to,
            'Check Response Body Containing EntityType element':
                Checks.check_response_body_containing_entitytype_element,
            'Check Response Body Containing EntityTypeInfo element':
@@ -255,6 +257,10 @@ class Checks:
                'params': ['filename', 'response'],
                'position': [0, 1]
            },
            'Check Response Body Containing Attribute Value set to': {
                'params': ['expected_value', 'response'],
                'position': [0, 1]
            },
            'Check Response Body Containing EntityType element': {
                'params': ['filename', 'response'],
                'position': [0, 1]
@@ -827,6 +833,13 @@ class Checks:
        else:
            raise Exception(f"ERROR, expected filename and response attributes, but received: {kwargs}")

    @staticmethod
    def check_response_body_containing_attribute_value_set_to(kwargs: list) -> str:
        if 'expected_value' in kwargs:
            return f"Response Body containing the value only Attribute fragment '{kwargs['expected_value']}'"
        else:
            raise Exception(f"ERROR, expected expected_value attribute, but received: {kwargs}")

    @staticmethod
    def check_response_body_containing_entitytype_element(kwargs: list) -> str:
        if 'filename' in kwargs and 'response' in kwargs:
+10 −0
Changes for doc/analysis/requests.py: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ class Requests:
                'positions': [],
                'params': ['id', 'attr_id', 'context', 'datasetId', 'lang', 'type']
            },
            'Retrieve Entity Attribute Value': {
                'positions': [],
                'params': ['id', 'attr_id', 'context', 'datasetId', 'lang', 'type']
            },
            'Retrieve Entity Type': {
                'positions': [0, 1],
                'params': ['type', 'context']
@@ -349,6 +353,8 @@ class Requests:
                Requests.retrieve_attribute,
            'Retrieve Entity Attribute':
                Requests.retrieve_entity_attribute,
            'Retrieve Entity Attribute Value':
                Requests.retrieve_entity_attribute_value,
            'Retrieve Entity Type':
                Requests.retrieve_entity_type,
            'Query Entities':
@@ -1380,6 +1386,10 @@ class Requests:
    def retrieve_entity_attribute(kwargs) -> str:
        return Requests.entity_attribute_description("Retrieve Entity Attribute", kwargs)

    @staticmethod
    def retrieve_entity_attribute_value(kwargs) -> str:
        return Requests.entity_attribute_description("Retrieve Entity Attribute Value", kwargs)

    @staticmethod
    def retrieve_attribute(kwargs) -> str:
        if 'attribute_name' in kwargs:
+25 −0
Changes for resources/ApiUtils/ContextInformationConsumption.resource: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -357,6 +357,31 @@ Retrieve Entity Attribute
    Output    ${response}    Retrieve Entity Attribute
    RETURN    ${response}

Retrieve Entity Attribute Value
    [Documentation]    GET /entities/{entityId}/attrs/{attrId}/value: the value only Attribute fragment
    [Tags]    actor_context-consumer
    [Arguments]
    ...    ${id}
    ...    ${attr_id}
    ...    ${context}=${EMPTY}
    ...    ${datasetId}=${EMPTY}
    ...    ${lang}=${EMPTY}
    ...    ${type}=${EMPTY}

    ${headers}    ${params}=    Build Entity Attribute Request
    ...    ${context}
    ...    ${EMPTY}
    ...    ${datasetId}
    ...    ${lang}
    ...    ${type}
    ${response}=    GET
    ...    url=${url}${NGSI_LD_API_PATH}/${ENTITIES_ENDPOINT_PATH}${id}/attrs/${attr_id}/value
    ...    headers=${headers}
    ...    params=${params}
    ...    expected_status=any
    Output    ${response}    Retrieve Entity Attribute Value
    RETURN    ${response}

Build Entity Attribute Request
    [Documentation]    The headers and the URL parameters of a GET on an Attribute or its value
    [Arguments]    ${context}    ${accept}    ${datasetId}    ${lang}    ${type}
Loading