Commit 94f2f4b3 authored by Ken Zangelin's avatar Ken Zangelin
Browse files

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

parent de15ee9a
Loading
Loading
Loading
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