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

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

  • 062_02: the value only representation (TS 104-175 5.4.2), compared as JSON: a String, a Number, a JSON Object and a JSON Array Property, a LanguageProperty (its languageMap), and the same LanguageProperty with lang=fr (the string, 7.2.7)
  • 062_04: 400 for an invalid entity id, 404 for an unknown entity, 404 for an unknown attribute

9 Test Cases in TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/, next to the Retrieve Attribute TCs of !327 (merged). Same conventions as !327 (merged) after its review: since_ts104_v1.1.1, the template argument named as its column, the ProblemDetails title checked in 062_04 and the Content-Type in 062_02.

Also in the MR:

  • the keyword Retrieve Entity Attribute Value (resources/ApiUtils/ContextInformationConsumption.resource), sharing Build Entity Attribute Request with Retrieve Entity Attribute
  • the check Check Response Body Containing Attribute Value set to (resources/AssertionUtils.resource): the expected value is JSON text, compared as JSON
  • the entity sample data/entities/building-value-kinds.jsonld
  • the documentation-generator entries (doc/analysis/checks.py, requests.py)
  • a robocop format fix on two lines that came with !327 (merged) (b3867de3): the datasetId IF of Build Entity Attribute Request on three lines, the 062_06_02 name

Doc unit tests 12/12, statisticsDocumentationData.py 0 of 578 failed, robocop format --check clean. Against coraine: 9/9.

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

Edited by Ken Zangelin

Merge request reports

Loading
+62 −0
Changes for TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/062_02.robot: 62 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-value-kinds.jsonld


*** Test Cases ***    ATTRIBUTE    LANG    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    ${EMPTY}    "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    ${EMPTY}    4
062_02_03 Retrieve The Value Of A Property Whose Value Is A JSON Object
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    core_10_4_4    http_7_6_3_1
    address    ${EMPTY}    {"streetAddress": "Champ de Mars", "addressLocality": "Paris"}
062_02_04 Retrieve The Value Of A Property Whose Value Is A JSON Array
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    core_10_4_4    http_7_6_3_1
    category    ${EMPTY}    ["monument", "tourism"]
062_02_05 Retrieve The Value Of A LanguageProperty
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    core_10_4_4    http_7_6_3_1
    street    ${EMPTY}    {"fr": "Grand Place", "nl": "Grote Markt"}
062_02_06 Retrieve The Value Of A LanguageProperty In One Language
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    core_10_4_4    http_7_6_3_1
    street    fr    "Grand Place"


*** 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}    ${lang}    ${expected_value}

    ${response}=    Retrieve Entity Attribute Value
    ...    id=${entity_id}
    ...    attr_id=${attribute}
    ...    context=${ngsild_test_suite_context}
    ...    lang=${lang}
    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()}
+1 −1
Changes for TP/NGSI-LD/ContextInformation/Consumption/EntityAttributes/RetrieveAttributeValue/062_06.robot: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ ${filename}= building-language-property.jsonld
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
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

+34 −0
Changes for data/entities/building-value-kinds.jsonld: 34 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:Building:randomUUID",
  "type": "Building",
  "name": {
    "type": "Property",
    "value": "Eiffel Tower"
  },
  "airQualityLevel": {
    "type": "Property",
    "value": 4
  },
  "address": {
    "type": "Property",
    "value": {
      "streetAddress": "Champ de Mars",
      "addressLocality": "Paris"
    }
  },
  "category": {
    "type": "Property",
    "value": [
      "monument",
      "tourism"
    ]
  },
  "street": {
    "type": "LanguageProperty",
    "languageMap": {
      "fr": "Grand Place",
      "nl": "Grote Markt"
    }
  },
  "@context": "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
}
+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 ContextSourceIdentity element':
                Checks.check_response_body_containing_contextsourceidentity_element,
            'Check Response Body Containing EntityType element':
@@ -259,6 +261,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 ContextSourceIdentity element': {
                'params': ['response_body'],
                'position': [0]
@@ -839,6 +845,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_contextsourceidentity_element(kwargs: list) -> str:
        if 'response_body' in kwargs:
Loading
Loading