Commit 6795c2a6 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat: add TCs for format and options query params

parent a7625d78
Loading
Loading
Loading
Loading
+76 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve an entity with format or options query params

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 Format Or Options Query Params


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


*** Test Cases ***    FORMAT_VALUE    OPTIONS_VALUE    EXPECTATION_FILENAME
018_15_01 RetrieveWithKeyValuesFormat
    [Documentation]    Check that one can retrieve with format query param having keyValues value
    [Tags]    e-retrieve    5_7_1    6_3_7    since_v1.8.1
    keyValues    ${EMPTY}    building-simple-attributes-simplified.jsonld
018_15_02 RetrieveWithSimplifiedFormat
    [Documentation]    Check that one can retrieve with format query param having simplified value
    [Tags]    e-retrieve    5_7_1    6_3_7    since_v1.8.1
    simplified    ${EMPTY}    building-simple-attributes-simplified.jsonld
018_15_03 RetrieveWithNormalizedFormat
    [Documentation]    Check that one can retrieve with format query param having normalized value
    [Tags]    e-retrieve    5_7_1    6_3_7    since_v1.8.1
    normalized    ${EMPTY}    building-simple-attributes.jsonld
018_15_04 RetrieveWithKeyValuesOptions
    [Documentation]    Check that one can retrieve with options query param having keyValues value
    [Tags]    e-retrieve    5_7_1    6_3_7    since_v1.8.1
    ${EMPTY}    keyValues    building-simple-attributes-simplified.jsonld
018_15_05 RetrieveWithSimplifiedOptions
    [Documentation]    Check that one can retrieve with options query param having simplified value
    [Tags]    e-retrieve    5_7_1    6_3_7    since_v1.8.1
    ${EMPTY}    simplified    building-simple-attributes-simplified.jsonld
018_15_06 RetrieveWithNormalizedOptions
    [Documentation]    Check that one can retrieve with options query param having normalized value
    [Tags]    e-retrieve    5_7_1    6_3_7    since_v1.8.1
    ${EMPTY}    normalized    building-simple-attributes.jsonld
018_15_07 RetrieveWithFormatAndOptions
    [Documentation]    Check that one can retrieve with both format and options query params
    [Tags]    e-retrieve    5_7_1    6_3_7    since_v1.8.1
    keyValues    normalized    building-simple-attributes-simplified.jsonld


*** Keywords ***
Retrieve Entity With Format Or Options Query Params
    [Documentation]    Retrieve an entity giving format or options query params different values
    [Arguments]    ${format_value}    ${options_value}    ${expectation_filename}
    ${response}=    Query Entity
    ...    id=${entity_id}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ...    format=${format_value}
    ...    options=${options_value}

    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing Entity element
    ...    ${expectation_filename}
    ...    ${entity_id}
    ...    ${response.json()}
    ...    ${True}

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 by Id    ${entity_id}
+50 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Documentation       Check that retrieve entity returns an error when queried with faulty format or options query params

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

Test Template       Retrieve Entity With Faulty Format Or Options Query Params


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


*** Test Cases ***    FORMAT_VALUE    OPTIONS_VALUE
018_16_01 RetriveWithInvalidFormat
    [Documentation]    Check that retrieving an entity with invalid format query param returns an error
    [Tags]    e-retrieve    5_7_1    6_3_7    6_3_20    since_v1.8.1
    invalidFormat    ${EMPTY}
018_16_02 RetriveWithInvalidOptions
    [Documentation]    Check that retrieving an entity with invalid options query param returns an error
    [Tags]    e-retrieve    5_7_1    6_3_7    6_3_20    since_v1.8.1
    ${EMPTY}    invalidOptions
018_16_03 RetriveWithAtLeastOneInvalidOptions
    [Documentation]    Check that retrieving an entity with at least one invalid options query param returns an error
    [Tags]    e-retrieve    5_7_1    6_3_7    6_3_20    since_v1.8.1
    ${EMPTY}    keyValues,invalid
018_16_04 RetriveWithOneInvalidQueryParam
    [Documentation]    Check that retrieving an entity with one invalid query param returns an error
    [Tags]    e-retrieve    5_7_1    6_3_7    6_3_20    since_v1.8.1
    keyValues    invalid


*** Keywords ***
Retrieve Entity With Faulty Format Or Options Query Params
    [Documentation]    Retrieve Entity with faulty format or options query params and check the returned error
    [Arguments]    ${format_value}    ${options_value}
    ${entity_id}=    Generate Random Building Entity Id
    Set Suite Variable    ${entity_id}
    ${response}=    Query Entity
    ...    id=${entity_id}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ...    format=${format_value}
    ...    options=${options_value}

    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_INVALID_REQUEST}
+71 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Documentation       Check that one can query the temporal evolution of an entity with format or options query params

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

Suite Setup         Setup Initial Entities
Suite Teardown      Delete Initial Entities
Test Template       Query The Temporal Evolution of An Entity With Format Or Options Query Params


*** Variables ***
${first_vehicle_payload_file}=      2020-08-vehicle-temporal-representation.jsonld
${second_vehicle_payload_file}=     2020-09-vehicle-temporal-representation.jsonld


*** Test Cases ***    FORMAT_VALUE    OPTIONS_VALUE    AGGRMETHODS    EXPECTATION_FILENAME
021_19_01 QueryWithFormatOnly
    [Documentation]    Check that one can query the temporal evolution with format query param only
    [Tags]    te-retrieve    5_7_3    6_3_12    since_v1.8.1
    temporalValues    ${EMPTY}    ${EMPTY}    vehicles-temporal-representation-021-19-01.json
021_19_02 QueryWithFormatAndOptions
    [Documentation]    Check that if both format and options are present, the value of the format parameter takes precedence
    [Tags]    te-retrieve    5_7_3    6_3_12    since_v1.8.1
    temporalValues    aggregatedValues    sum    vehicles-temporal-representation-021-19-01.json
021_19_03 QueryWithOptionsOnly
    [Documentation]    Check that one can query the temporal evolution with options query param only
    [Tags]    te-retrieve    5_7_3    6_3_12    since_v1.8.1
    ${EMPTY}    temporalValues    ${EMPTY}    vehicles-temporal-representation-021-19-01.json


*** Keywords ***
Query The Temporal Evolution of An Entity With Format Or Options Query Params
    [Documentation]    Query the temporal evolution of an entity giving format or options query params different values
    [Arguments]    ${format_value}    ${options_value}    ${aggr_methods}    ${expectation_file}
    @{types}=    Create List    Vehicle

    ${response}=    Query Temporal Representation Of Entities
    ...    entity_types=${types}
    ...    options=${options_value}
    ...    format=${format_value}
    ...    aggrMethods=${aggr_methods}
    ...    context=${ngsild_test_suite_context}
    ...    timerel=after
    ...    timeAt=2020-01-01T12:03:00Z

    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing EntityTemporal elements
    ...    ${expectation_file}
    ...    ${response.json()}

Setup Initial Entities
    ${first_temporal_entity_representation_id}=    Catenate    ${VEHICLE_ID_PREFIX}021-19-A
    ${create_response1}=    Create Temporal Representation Of Entity
    ...    ${first_vehicle_payload_file}
    ...    ${first_temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response1.status_code}
    Set Suite Variable    ${first_temporal_entity_representation_id}
    ${second_temporal_entity_representation_id}=    Catenate    ${VEHICLE_ID_PREFIX}021-19-B
    ${create_response2}=    Create Temporal Representation Of Entity
    ...    ${second_vehicle_payload_file}
    ...    ${second_temporal_entity_representation_id}
    Check Response Status Code    201    ${create_response2.status_code}
    Set Suite Variable    ${second_temporal_entity_representation_id}

Delete Initial Entities
    Delete Temporal Representation Of Entity    ${first_temporal_entity_representation_id}
    Delete Temporal Representation Of Entity    ${second_temporal_entity_representation_id}
+53 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot query the temporal evolution of entities when called with faulty format or options query params

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

Test Template       Query The Temporal Evolution of An Entity With Faulty Format Or Options Query Params


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


*** Test Cases ***    FORMAT_VALUE    OPTIONS_VALUE
021_20_01 QueryWithInvalidFormat
    [Documentation]    Check that one cannot query with an invalid format query param
    [Tags]    te-retrieve    5_7_3    6_3_12    6_3_20    since_v1.8.1
    invalidFormat    ${EMPTY}
021_20_02 QueryWithInvalidOptions
    [Documentation]    Check that one cannot query with an invalid options query param
    [Tags]    te-retrieve    5_7_3    6_3_12    6_3_20    since_v1.8.1
    ${EMPTY}    invalidOptions
021_20_03 QueryWithAtLeastOneInvalidOptions
    [Documentation]    Check that one cannot query with at least one invalid options query param
    [Tags]    te-retrieve    5_7_3    6_3_12    6_3_20    since_v1.8.1
    ${EMPTY}    temporalValues,invalidOptions
021_20_04 QueryWithOneInvalidQueryParam
    [Documentation]    Check that one cannot query with at least one invalid query param
    [Tags]    te-retrieve    5_7_3    6_3_12    6_3_20    since_v1.8.1
    temporalValues    aggregatedValues,invalidOptions


*** Keywords ***
Query The Temporal Evolution of An Entity With Faulty Format Or Options Query Params
    [Documentation]    Query the temporal evolution of an entity with faulty format or options query params and check the returned error
    [Arguments]    ${format_value}    ${options_value}
    @{types}=    Create List    Vehicle
    ${temporal_entity_representation_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${temporal_entity_representation_id}

    ${response}=    Query Temporal Representation Of Entities
    ...    entity_types=${types}
    ...    options=${options_value}
    ...    format=${format_value}
    ...    context=${ngsild_test_suite_context}
    ...    timerel=after
    ...    timeAt=2020-01-01T12:03:00Z
    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_INVALID_REQUEST}
+42 −0
Original line number Original line Diff line number Diff line
{
    "id": "urn:ngsi-ld:Vehicle:randomUUID",
    "type": "Vehicle",
    "fuelLevel": {
        "type": "Property",
        "values": [
            [
                67.0,
                "2020-08-01T12:03:00Z"

            ],
            [
                53.0,
                "2020-08-01T13:05:00Z"
            ],
            [
                40.0,
                "2020-08-01T14:07:00Z"
            ]

        ]
    },
    "speed": {
        "type": "Property",
        "values": [
            [
                120.0,
                "2020-08-01T12:03:00Z"

            ],
            [
                80.0,
                "2020-08-01T12:05:00Z"
            ],
            [
                100.0,
                "2020-08-01T12:07:00Z"
            ]

        ]
    }
}
 No newline at end of file
Loading