Unverified Commit a3945683 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat(pick-omit): add TCs for 404 error when retrieving entities

parent d25479a0
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a ResourceNotFound error is returned if the entity has no members left after applying pick and omit query params

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

Test Setup          Create Initial Entity
Test Teardown       Delete Created Entity
Test Template       Retrieve Entity With Pick And Omit Query Params


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


*** Test Cases ***    PICK    OMIT
018_19_01 RetrieveWithUnmatchedPick
    [Documentation]    Check that a ResourceNotFound error is returned if pick does not match any entity member
    [Tags]    e-retrieve    5_7_1    4_21    since_v1.8.1
    unknown    ${EMPTY}
018_19_02 RetrieveWithFullExcludingOmit
    [Documentation]    Check that a ResourceNotFound error is returned if omit contains all entity members
    [Tags]    e-retrieve    5_7_1    4_21    since_v1.8.1
    ${EMPTY}    id,type,name,subCategory,airQualityLevel,almostFull


*** Keywords ***
Retrieve Entity With Pick And Omit Query Params
    [Documentation]    Check that a ResourceNotFound error is returned if the entity has no members left after applying pick and omit query params
    [Arguments]    ${pick}    ${omit}
    ${response}=    Retrieve Entity
    ...    id=${entity_id}
    ...    accept=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    ...    pick=${pick}
    ...    omit=${omit}

    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}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}

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

Delete Created Entity
    Delete Entity    ${entity_id}
+56 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a ResourceNotFound error is returned if the temporal entity has no members left after applying pick and omit query params

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Create Temporal Entity
Test Teardown       Delete Initial Temporal Entity
Test Template       Retrieve Temporal Entity With Pick And Omit Query Params


*** Variables ***
${vehicle_payload_file}=    2020-08-vehicle-temporal-representation.jsonld


*** Test Cases ***    PICK    OMIT
020_23_01 RetrieveWithUnmatchedPick
    [Documentation]    Check that a ResourceNotFound error is returned if pick does not match any entity member
    [Tags]    te-retrieve    5_7_3    4_21    since_v1.8.1
    unknown    ${EMPTY}
020_23_02 RetrieveWithFullExcludingOmit
    [Documentation]    Check that a ResourceNotFound error is returned if omit contains all entity members
    [Tags]    te-retrieve    5_7_3    4_21    since_v1.8.1
    ${EMPTY}    id,type,fuelLevel,speed


*** Keywords ***
Retrieve Temporal Entity With Pick And Omit Query Params
    [Documentation]    Check that a ResourceNotFound error is returned if the entity has no members left after applying pick and omit query params
    [Arguments]    ${pick}    ${omit}
    ${response}=    Retrieve Temporal Representation Of Entity
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    accept=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    ...    pick=${pick}
    ...    omit=${omit}

    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}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}

Create Temporal Entity
    ${temporal_entity_representation_id}=    Generate Random Vehicle Entity Id
    ${create_response}=    Create Temporal Representation Of Entity
    ...    ${vehicle_payload_file}
    ...    ${temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response.status_code}
    Set Suite Variable    ${temporal_entity_representation_id}

Delete Initial Temporal Entity
    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}
+14 −0
Original line number Diff line number Diff line
@@ -469,6 +469,13 @@ class TestCIConsumptions(TestCase):

        self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)

    def test_018_19(self):
        robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/Entity/RetrieveEntity/018_19.robot'
        expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/018_19.json'
        difference_file = f'{self.folder_test_suites}/doc/results/out_018_19.json'

        self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)

    def test_021_01(self):
        robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/QueryTemporalEvolutionOfEntities/021_01.robot'
        expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/021_01.json'
@@ -775,3 +782,10 @@ class TestCIConsumptions(TestCase):
        difference_file = f'{self.folder_test_suites}/doc/results/out_020_22.json'

        self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)

    def test_020_23(self):
        robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Consumption/TemporalEntity/RetrieveTemporalEvolutionOfEntity/020_23.robot'
        expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Consumption/020_23.json'
        difference_file = f'{self.folder_test_suites}/doc/results/out_020_23.json'

        self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ ${TEMPORAL_ENTITIES_ENDPOINT_PATH} temporal/entities
${ENTITIES_TYPES_ENDPOINT_PATH}         types

${ERROR_TYPE_INVALID_REQUEST}           https://uri.etsi.org/ngsi-ld/errors/InvalidRequest
${ERROR_TYPE_RESOURCE_NOT_FOUND}        https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound


*** Keywords ***
Build Context Link