feat(entity): add TCs for Retrieve Attribute (062_01 fragment, 062_03 errors, 062_05 datasetId)

New Test Cases for Retrieve Attribute, GET /entities/{entityId}/attrs/{attrId} (TS 104-176 7.5.3.1, TS 104-175 10.4.4). Until now the suite did not test this operation.

  • 062_01: the attribute fragment, for a Property and for a second attribute
  • 062_03: 400 for an invalid entity id, 404 for an unknown entity, 404 for an unknown attribute
  • 062_05: datasetId: the instance it names; 404 when the attribute has no default instance and no datasetId is given; 404 for an unknown datasetId
  • 062_06: lang: a LanguageProperty in one language; the whole LanguageProperty without lang
  • 062_07: type: the Entity's type gives 200, another type 404 (TS 104-175 10.4.4.4)

12 Test Cases in TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/ (TP ids CI/Cons/EA/062_xx), all tagged since_ts104_v1.1.1: the operation has no ETSI GS CIM 009 counterpart. doc/README.md documents that tag form, and statisticsDocumentationData.py keeps the whole release after since_.

Also in the MR:

  • the keyword Retrieve Entity Attribute (resources/ApiUtils/ContextInformationConsumption.resource)
  • the expectation files in data/entities/expectations/
  • the documentation-generator entries (doc/analysis/requests.py, generaterobotdata.py)

Scope: this MR covers 7.5.3.1, the attribute fragment. 062_02 and 062_04 are kept free for 7.6.3.1 (GET .../attrs/{attrId}/value), which comes in the next MR and reuses the same helpers. Set Attribute Value (063) follows after that. Not covered here: join/joinLevel (they exist only on 7.5.3.1, so they need a keyword of their own) and the EntityMap parameters.

The dry run (12/12) and the documentation generator are clean. Against a broker: 11 of 12 pass. 062_07_02 fails because that broker ignores type on this route, which is a broker bug.

MR 4 of the plan: https://famzang.com/ttf/ngsi-ld-suite-plan.html

Edited by Ken Zangelin

Merge request reports

Loading
+50 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/062_01.robot: 50 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve an Attribute of an Entity: the response body is the Attribute fragment

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

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


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


*** Test Cases ***    ATTRIBUTE    EXPECTATION_FILENAME
062_01_01 Retrieve A Property
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    name    attribute-fragment-name.json
062_01_02 Retrieve A Property With Sub-Attributes
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    airQualityLevel    attribute-fragment-airqualitylevel.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 Suite Variable    ${entity_id}

Delete Initial Entity
    Delete Entity    ${entity_id}

Retrieve An Attribute Of An Entity
    [Documentation]    Check that one can retrieve an Attribute of an Entity
    [Arguments]    ${attribute}    ${expectation_filename}

    ${response}=    Retrieve Entity Attribute
    ...    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 Content    ${expectation_filename}    ${response.json()}
+54 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/062_03.robot: 54 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot retrieve 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 An Attribute With An Error


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


*** Test Cases ***    ENTITY_ID    ATTRIBUTE    EXPECTED_STATUS_CODE    PROBLEM_TYPE
062_03_01 Retrieve An Attribute If The Entity Id Is Not A Valid URI
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    thisisaninvaliduri    name    400    ${ERROR_TYPE_BAD_REQUEST_DATA}
062_03_02 Retrieve An Attribute If The Entity Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    urn:ngsi-ld:Building:unknown062    name    404    ${ERROR_TYPE_RESOURCE_NOT_FOUND}
062_03_03 Retrieve An Attribute If The Attribute Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_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 An Attribute With An Error
    [Documentation]    Check that one cannot retrieve 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
    ...    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()}
+66 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/062_05.robot: 66 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve an Attribute instance by its datasetId, and that an Attribute with no instance for the datasetId asked (or no default instance, when none is asked) is not found (404)

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

Suite Setup         Create Initial Entity
Suite Teardown      Delete Initial Entity


*** Variables ***
${filename}=    vehicle-speed-two-datasetid.jsonld


*** Test Cases ***
062_05_01 Retrieve An Attribute Instance By datasetId
    [Documentation]    Check that the datasetId parameter selects the Attribute instance returned
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    ${response}=    Retrieve Entity Attribute
    ...    id=${entity_id}
    ...    attr_id=speed
    ...    context=${ngsild_test_suite_context}
    ...    datasetId=urn:ngsi-ld:Property:speedometer
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Content    attribute-fragment-speed-speedometer.json    ${response.json()}

062_05_02 Retrieve An Attribute Without A Default Instance
    [Documentation]    Check that an Attribute that has no default instance is not found when no datasetId is given
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    ${response}=    Retrieve Entity Attribute
    ...    id=${entity_id}
    ...    attr_id=speed
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    404    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_RESOURCE_NOT_FOUND}

062_05_03 Retrieve An Attribute Instance By An Unknown datasetId
    [Documentation]    Check that an Attribute that has no instance with the datasetId given is not found
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    ${response}=    Retrieve Entity Attribute
    ...    id=${entity_id}
    ...    attr_id=speed
    ...    context=${ngsild_test_suite_context}
    ...    datasetId=urn:ngsi-ld:Property:unknown062
    Check Response Status Code    404    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_RESOURCE_NOT_FOUND}


*** Keywords ***
Create Initial Entity
    ${entity_id}=    Generate Random Vehicle 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}
+50 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/062_06.robot: 50 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve a LanguageProperty of an Entity: in the language the lang parameter selects, or whole when no lang is given

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

Suite Setup         Create Initial Entity
Suite Teardown      Delete Initial Entity
Test Template       Retrieve A LanguageProperty Of An Entity


*** Variables ***
${filename}=    building-language-property.jsonld


*** Test Cases ***    LANG    EXPECTATION_FILENAME
062_06_01 Retrieve A LanguageProperty In One Language
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    fr    attribute-fragment-street-fr.json
062_06_02 Retrieve A LanguageProperty Without lang
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    ${EMPTY}    attribute-fragment-street-languagemap.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 Suite Variable    ${entity_id}

Delete Initial Entity
    Delete Entity    ${entity_id}

Retrieve A LanguageProperty Of An Entity
    [Documentation]    Check that the lang parameter selects the language of the LanguageProperty returned
    [Arguments]    ${lang}    ${expectation_filename}

    ${response}=    Retrieve Entity Attribute
    ...    id=${entity_id}
    ...    attr_id=street
    ...    context=${ngsild_test_suite_context}
    ...    lang=${lang}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Content    ${expectation_filename}    ${response.json()}
+54 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/062_07.robot: 54 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that the type parameter of a Retrieve Attribute selects the Entity: an Entity of that type has its Attribute returned, an Entity of another type is not found (404)

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

Suite Setup         Create Initial Entity
Suite Teardown      Delete Initial Entity


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


*** Test Cases ***
062_07_01 Retrieve An Attribute Of An Entity Of The Type Given
    [Documentation]    Check that the Attribute is returned when the Entity has the type given
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    ${response}=    Retrieve Entity Attribute
    ...    id=${entity_id}
    ...    attr_id=name
    ...    context=${ngsild_test_suite_context}
    ...    type=Building
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Content    attribute-fragment-name.json    ${response.json()}

062_07_02 Retrieve An Attribute Of An Entity Of Another Type
    [Documentation]    Check that the Entity is not found when it does not have the type given
    [Tags]    since_ts104_v1.1.1    ea-retrieve    core_10_4_4    http_7_5_3_1
    ${response}=    Retrieve Entity Attribute
    ...    id=${entity_id}
    ...    attr_id=name
    ...    context=${ngsild_test_suite_context}
    ...    type=Vehicle
    Check Response Status Code    404    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_RESOURCE_NOT_FOUND}


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