Commit 01a8b81f authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat: add minimal TCS for broader local queries

parent 1533364e
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot query entities if it has none of the minimal parameters

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


*** Variables ***
${entity_id_one}=       urn:ngsi-ld:Entity:01
${entity_id_two}=       urn:ngsi-ld:Entity:02


*** Test Cases ***
019_03_05 Query Entities Without Minimal Parameters
    [Documentation]    Check that one cannot query entities if it has none of the minimal parameters
    [Tags]    e-query    5_7_2
    ${entities_ids_to_be_retrieved}=    Catenate    SEPARATOR=,    ${entity_id_one}    ${entity_id_two}

    ${response}=    Query Entities
    ...    entity_ids=${entities_ids_to_be_retrieved}

    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}
+54 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can query all entities if query is local

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

Suite Setup         Setup Initial Entities
Suite Teardown      Delete Entities


*** Variables ***
${filename}=                building-minimal.jsonld
${expectation_filename}=    building-minimal.json


*** Test Cases ***
019_25 Query All Entities With Local Flag
    [Documentation]    Check that one can query all entities if query is local
    [Tags]    e-query    5_7_2
    @{entities_ids_to_be_compared}=    Create List    ${first_entity_id}    ${second_entity_id}

    ${response}=    Query Entities
    ...    local=true

    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing List Containing Entity Elements
    ...    expectation_filename=${expectation_filename}
    ...    entities_ids=${entities_ids_to_be_compared}
    ...    response_body=${response.json()}


*** Keywords ***
Setup Initial Entities
    ${first_entity_id}=    Generate Random Building Entity Id
    Set Suite Variable    ${first_entity_id}
    ${create_response1}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${first_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response1.status_code}
    ${second_entity_id}=    Generate Random Building Entity Id
    Set Suite Variable    ${second_entity_id}
    ${create_response2}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${second_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response2.status_code}

Delete Entities
    Delete Entity    ${first_entity_id}
    Delete Entity    ${second_entity_id}
+31 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can not query the temporal evolution of entities if it has none of the minimal parameters

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


*** Variables ***
${entity_id_one}=       urn:ngsi-ld:Entity:01
${entity_id_two}=       urn:ngsi-ld:Entity:02


*** Test Cases ***
021_24 Query Temporal Evolution Of Entities Without Minimal Parameters
    [Documentation]    Check that one can not query the temporal evolution of entities if it has none of the minimal parameters
    [Tags]    te-query    5_7_4
    ${entities_ids_to_be_retrieved}=    Catenate    SEPARATOR=,    ${entity_id_one}    ${entity_id_two}

    ${response}=    Query Temporal Representation Of Entities
    ...    entity_ids=${entities_ids_to_be_retrieved}
    ...    timerel=after
    ...    timeAt=2020-07-01T12:05:00Z
    ...    context=${ngsild_test_suite_context}

    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}
+54 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can query all temporal evolution of entities if query is local

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 Temporal Entities
Suite Teardown      Delete Initial Temporal Entities


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


*** Test Cases ***
021_25 Query All Temporal Entities With Local Flag
    [Documentation]    Check that one can query all temporal evolution of entities if query is local
    [Tags]    te-query    5_7_4    not-implemented

    ${response}=    Query Temporal Representation Of Entities
    ...    timerel=after
    ...    timeAt=2020-07-01T12:05:00Z
    ...    local=true
    ...    context=${ngsild_test_suite_context}

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


*** Keywords ***
Setup Initial Temporal Entities
    ${first_temporal_entity_representation_id}=    Catenate    ${VEHICLE_ID_PREFIX}021-06-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-06-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 Temporal Entities
    Delete Temporal Representation Of Entity    ${first_temporal_entity_representation_id}
    Delete Temporal Representation Of Entity    ${second_temporal_entity_representation_id}
+6 −4
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ class Requests:
                           'ngsild_query', 'csf', 'georel', 'geometry',
                           'coordinates', 'geoproperty', 'timerel', 'timeAt', 'endTimeAt',
                           'attrs', 'limit', 'lastN', 'accept', 'options', 'format', 'datasetId',
                           'aggrMethods', 'aggrPeriodDuration', 'pick', 'omit']
                           'aggrMethods', 'aggrPeriodDuration', 'pick', 'omit', 'local']
            },
            'Query Temporal Representation Of Entities Via Post': {
                'positions': [],
@@ -96,7 +96,7 @@ class Requests:
                           'attrs', 'context', 'geoproperty',
                           'options', 'limit', 'entity_id_pattern',
                           'scopeq', 'georel', 'coordinates', 'geometry', 'count', 'q', 'datasetId',
                           'join', 'joinLevel', 'pick', 'omit', 'orderBy']
                           'join', 'joinLevel', 'pick', 'omit', 'orderBy', 'local']
            },
            'Query Entities Via POST': {
                'positions': [],
@@ -1211,7 +1211,7 @@ class Requests:
                               'ngsild_query', 'csf', 'georel', 'geometry',
                               'coordinates', 'geoproperty', 'timerel', 'timeAt','endTimeAt',
                               'attrs', 'limit', 'lastN', 'accept', 'options', 'format', 'datasetId', 'aggrMethods',
                               'aggrPeriodDuration', 'pick', 'omit', 'orderBy', 'timeproperty']
                               'aggrPeriodDuration', 'pick', 'omit', 'orderBy', 'timeproperty', 'local']

        result = [x for x in kwargs if x not in expected_parameters]
        response = "Query Temporal Representation of Entities"
@@ -1271,6 +1271,8 @@ class Requests:
                    response = f"{response} and\n    Query Parameter: omit set to '{value}'"
                case 'orderBy':
                    response = f"{response} and\n    Query Parameter: orderBy set to '{value}'"
                case 'local':
                    response = f"{response} and\n    Query Parameter: local set to '{value}'"

            # If an exact match is not confirmed, this last case will be used if provided
                case _:
@@ -1350,7 +1352,7 @@ class Requests:
                               'attrs', 'context', 'geoproperty',
                               'options', 'limit', 'entity_id_pattern',
                               'scopeq', 'georel', 'coordinates', 'geometry', 'count' , 'q' , 'datasetId',
                               'join', 'joinLevel', 'pick', 'omit', 'local', 'orderBy']
                               'join', 'joinLevel', 'pick', 'omit', 'local', 'orderBy', 'local']

        result = [x for x in kwargs if x not in expected_parameters]
        response = "Get Entities Request:"
Loading