019_02_04.robot 2.21 KB
Newer Older
root's avatar
root committed
*** Settings ***
Documentation   Check that you can query several entities via POST Interaction based on attribute names
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${building_id_prefix}=  urn:ngsi-ld:Building:
${filename}=  building-minimal-sample.jsonld
lopesg's avatar
lopesg committed
${expectation_filename}=  building-minimal-expectation.jsonld
${attribute_airqualitylevel}=  https://ngsi-ld-test-suite/context#airQualityLevel
${attribute_subcategory}=  https://ngsi-ld-test-suite/context#subCategory
root's avatar
root committed

*** Test Cases ***                                                 
lopesg's avatar
lopesg committed
Query several entities via POST Interaction based on attribute names
root's avatar
root committed
    [Documentation]  Check that you can query several entities via POST Interaction based on attribute names
lopesg's avatar
lopesg committed
    [Tags]  /entityOperations/query    5_7_2
root's avatar
root committed

    ${first_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${request}    ${response}=    Create Entity Selecting Content Type  ${filename}     ${first_entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  201    ${response['status']}
    ${second_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${request}    ${response}=    Create Entity Selecting Content Type  ${filename}     ${second_entity_id}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code  201    ${response['status']}

    ${attributes_to_be_retrieved}=  Catenate    SEPARATOR=,   ${attribute_airqualitylevel}    ${attribute_subcategory}
root's avatar
root committed
    @{entities_ids_to_be_retrieved}=  Create List   ${first_entity_id}    ${second_entity_id}
    ${response}=    Query Entities Via POST    attrs=${attributes_to_be_retrieved}
    Check Response Status Code  200    ${response['status']}
root's avatar
root committed
    Check Response Body Containing List Containing Entity elements    ${expectation_filename}    ${entities_ids_to_be_retrieved}    ${response['body']}
root's avatar
root committed

    [Teardown]  Delete Entities    ${first_entity_id}    ${second_entity_id}


*** Keywords ***
Delete Entities
    [Arguments]  ${first_entity_id}    ${second_entity_id}
    Delete Entity by Id Returning Response   ${first_entity_id}
    Delete Entity by Id Returning Response   ${second_entity_id}