Unverified Commit 5c6063c8 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat(pick-omit): add TCs for Query Entities

parent ed39a9c1
Loading
Loading
Loading
Loading
+84 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can query entities with pick and omit query params

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
Test Template       Query Entities With Pick Or Omit Query Params


*** Test Cases ***    PICK    OMIT    EXPECTED_FILENAME
019_17_01 QueryWithPickOnAttributes
    [Documentation]    Check that one can query entities with pick on attributes
    [Tags]    e-query    5_7_2    4_21    since_v1.8.1
    name    ${EMPTY}    pick-omit/entities-pick-name.json
019_17_02 QueryWithOmitOnAttributes
    [Documentation]    Check that one can query entities with omit on attributes
    [Tags]    e-query    5_7_2    4_21    since_v1.8.1
    ${EMPTY}    name    pick-omit/entities-omit-name.json
019_17_03 QueryWithPickOnNonCoreMembers
    [Documentation]    Check that one can query entities with pick on core members
    [Tags]    e-query    5_7_2    4_21    since_v1.8.1
    id    ${EMPTY}    pick-omit/entities-pick-id.json
019_17_04 QueryWithOmitOnNonCoreMembers
    [Documentation]    Check that one can query entities with omit on core members
    [Tags]    e-query    5_7_2    4_21    since_v1.8.1
    ${EMPTY}    id    pick-omit/entities-omit-id.json
019_17_05 QueryWithPickOnAttributesAndCoreMembers
    [Documentation]    Check that one can query entities with pick on attributes and core members
    [Tags]    e-query    5_7_2    4_21    since_v1.8.1
    id,name    ${EMPTY}    pick-omit/entities-pick-id-name.json
019_17_06 QueryWithOmitOnAttributesAndCoreMembers
    [Documentation]    Check that one can query entities with omit on attributes and core members
    [Tags]    e-query    5_7_2    4_21    since_v1.8.1
    ${EMPTY}    type,name    pick-omit/entities-omit-type-name.json


*** Keywords ***
Query Entities With Pick Or Omit Query Params
    [Documentation]    Query entities giving pick or omit query params different values
    [Arguments]    ${pick}    ${omit}    ${expectation_filename}

    ${response}=    Query Entities
    ...    entity_types=Building,Vehicle
    ...    pick=${pick}
    ...    omit=${omit}
    ...    context=${ngsild_test_suite_context}

    Check Response Status Code    200    ${response.status_code}
    Check Response Body Content    ${expectation_filename}    ${response.json()}

Setup Initial Entities
    ${first_entity_id}=    Catenate    ${BUILDING_ID_PREFIX}019-17-1
    Set Suite Variable    ${first_entity_id}
    ${create_response1}=    Create Entity Selecting Content Type
    ...    building-simple-attributes.jsonld
    ...    ${first_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response1.status_code}

    ${second_entity_id}=    Catenate    ${VEHICLE_ID_PREFIX}019-17-2
    Set Suite Variable    ${second_entity_id}
    ${create_response2}=    Create Entity Selecting Content Type
    ...    vehicle-simple-attributes.jsonld
    ...    ${second_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response2.status_code}

    ${third_entity_id}=    Catenate    ${BUILDING_ID_PREFIX}019-17-3
    Set Suite Variable    ${third_entity_id}
    ${create_response3}=    Create Entity Selecting Content Type
    ...    building-simple-attributes-third.jsonld
    ...    ${third_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response3.status_code}

Delete Entities
    Delete Entity    ${first_entity_id}
    Delete Entity    ${second_entity_id}
    Delete Entity    ${third_entity_id}
+76 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a BadRequestDataException is returned if the Query Entities request is invalid with respect to pick and omit query params

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
Test Template       Query Entities With Invalid Pick Or Omit Query Params Usage


*** Test Cases ***    PICK    OMIT    ATTRS
018_18_01 RetrieveWithSameEntityMemberInPickAndOmit
    [Documentation]    Check that a BadRequestDataException is returned if an entity member is present in pick and omit
    [Tags]    e-query    5_7_2    4_21    since_v1.8.1
    name    name    ${EMPTY}
018_18_02 RetrieveWithPickAndAttrs
    [Documentation]    Check that a BadRequestDataException is returned if pick and attrs query params are present
    [Tags]    e-query    5_7_2    4_21    since_v1.8.1
    name    ${EMPTY}    category
018_18_03 RetrieveWithOmitAndAttrs
    [Documentation]    Check that a BadRequestDataException is returned if omit and attrs query params are present
    [Tags]    e-query    5_7_2    4_21    since_v1.8.1
    ${EMPTY}    name    category


*** Keywords ***
Query Entities With Invalid Pick Or Omit Query Params Usage
    [Documentation]    Check that a BadRequestDataException is returned if the Query Entities request is invalid with respect to pick and omit query params
    [Arguments]    ${pick}    ${omit}    ${attrs}

    ${response}=    Query Entities
    ...    entity_types=Building,Vehicle
    ...    pick=${pick}
    ...    omit=${omit}
    ...    attrs=${attrs}
    ...    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()}

Setup Initial Entities
    ${first_entity_id}=    Catenate    ${BUILDING_ID_PREFIX}019-18-1
    Set Suite Variable    ${first_entity_id}
    ${create_response1}=    Create Entity Selecting Content Type
    ...    building-simple-attributes.jsonld
    ...    ${first_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response1.status_code}

    ${second_entity_id}=    Catenate    ${VEHICLE_ID_PREFIX}019-18-2
    Set Suite Variable    ${second_entity_id}
    ${create_response2}=    Create Entity Selecting Content Type
    ...    vehicle-simple-attributes.jsonld
    ...    ${second_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response2.status_code}

    ${third_entity_id}=    Catenate    ${BUILDING_ID_PREFIX}019-18-3
    Set Suite Variable    ${third_entity_id}
    ${create_response3}=    Create Entity Selecting Content Type
    ...    building-simple-attributes-third.jsonld
    ...    ${third_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response3.status_code}

Delete Entities
    Delete Entity    ${first_entity_id}
    Delete Entity    ${second_entity_id}
    Delete Entity    ${third_entity_id}
+64 −0
Original line number Diff line number Diff line
[
    {
        "type": "Building",
        "name": {
            "type": "Property",
            "value": "Eiffel Tower"
        },
        "subCategory": {
            "type": "Property",
            "value": "tourism"
        },
        "airQualityLevel": {
            "type": "Property",
            "value": 4,
            "unitCode": "C62",
            "observedAt": "2020-09-09T16:40:00.000Z"
        },
        "almostFull": {
            "type": "Property",
            "value": false
        }
    },
    {
        "type": "Vehicle",
        "brandName": {
            "type": "Property",
            "value": "Mercedes"
        },
        "isParked": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:OffStreetParking:Downtown1",
            "observedAt": "2017-07-29T12:00:04Z",
            "providedBy": {
                "type": "Relationship",
                "object": "urn:ngsi-ld:Person:Bob"
            }
        }
    },
    {
        "type": "Building",
        "name": {
            "type": "Property",
            "value": "Pisa Tower"
        },
        "subCategory": {
            "type": "Property",
            "value": "sightseeing"
        },
        "airQualityLevel": {
            "type": "Property",
            "value": 7,
            "unitCode": "C62",
            "observedAt": "2023-10-10T16:40:00.000Z"
        },
        "almostFull": {
            "type": "Property",
            "value": false
        },
        "locatedIn": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:City:Pisa"
        }
    }
]
 No newline at end of file
+59 −0
Original line number Diff line number Diff line
[
    {
        "id": "urn:ngsi-ld:Building:019-17-1",
        "type": "Building",
        "subCategory": {
            "type": "Property",
            "value": "tourism"
        },
        "airQualityLevel": {
            "type": "Property",
            "value": 4,
            "unitCode": "C62",
            "observedAt": "2020-09-09T16:40:00.000Z"
        },
        "almostFull": {
            "type": "Property",
            "value": false
        }
    },
    {
        "id": "urn:ngsi-ld:Vehicle:019-17-2",
        "type": "Vehicle",
        "brandName": {
            "type": "Property",
            "value": "Mercedes"
        },
        "isParked": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:OffStreetParking:Downtown1",
            "observedAt": "2017-07-29T12:00:04Z",
            "providedBy": {
                "type": "Relationship",
                "object": "urn:ngsi-ld:Person:Bob"
            }
        }
    },
    {
        "id": "urn:ngsi-ld:Building:019-17-3",
        "type": "Building",
        "subCategory": {
            "type": "Property",
            "value": "sightseeing"
        },
        "airQualityLevel": {
            "type": "Property",
            "value": 7,
            "unitCode": "C62",
            "observedAt": "2023-10-10T16:40:00.000Z"
        },
        "almostFull": {
            "type": "Property",
            "value": false
        },
        "locatedIn": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:City:Pisa"
        }
    }
]
 No newline at end of file
+56 −0
Original line number Diff line number Diff line
[
    {
        "id": "urn:ngsi-ld:Building:019-17-1",
        "subCategory": {
            "type": "Property",
            "value": "tourism"
        },
        "airQualityLevel": {
            "type": "Property",
            "value": 4,
            "unitCode": "C62",
            "observedAt": "2020-09-09T16:40:00.000Z"
        },
        "almostFull": {
            "type": "Property",
            "value": false
        }
    },
    {
        "id": "urn:ngsi-ld:Vehicle:019-17-2",
        "brandName": {
            "type": "Property",
            "value": "Mercedes"
        },
        "isParked": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:OffStreetParking:Downtown1",
            "observedAt": "2017-07-29T12:00:04Z",
            "providedBy": {
                "type": "Relationship",
                "object": "urn:ngsi-ld:Person:Bob"
            }
        }
    },
    {
        "id": "urn:ngsi-ld:Building:019-17-3",
        "subCategory": {
            "type": "Property",
            "value": "sightseeing"
        },
        "airQualityLevel": {
            "type": "Property",
            "value": 7,
            "unitCode": "C62",
            "observedAt": "2023-10-10T16:40:00.000Z"
        },
        "almostFull": {
            "type": "Property",
            "value": false
        },
        "locatedIn": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:City:Pisa"
        }
    }
]
 No newline at end of file
Loading