Skip to content
046_08.robot 4.63 KiB
Newer Older
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed
*** Settings ***
Documentation       Check that a notification is only sent if and only if the status is active
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/NotificationUtils.resource
lopezaguilar's avatar
lopezaguilar committed
Library             ${EXECDIR}/libraries/logUtils.py
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

Suite Setup         Before Suite
Suite Teardown      After Suite
Test Teardown       After Test
*** Variables ***
${subscription_id_prefix}=              urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=      subscriptions/subscription-building-entities-active.jsonld
${building_id_prefix}=                  urn:ngsi-ld:Building:
${notification_server_send_url}=        http://${notification_server_host}:${notification_server_port}/notify
${entity_building_filepath}=            building-simple-attributes-sample.jsonld
${fragment_filename}=                   airQualityLevel-fragment.jsonld
lopezaguilar's avatar
lopezaguilar committed
046_08_01 Check that a notification is sent with all attributes
    [Documentation]    The structure of the notification message shall be as mandated by clause 5.3.1. The absence of the notification.attributes member of a Subscription means that all Entity Attributes shall be included. All attributes are included
    [Tags]    sub-notification    5_8_6
    [Setup]    Setup Initial Subscriptions    ${False}
    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    ${notification}    ${headers}=    Wait for notification    ${5}
Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed
    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Dictionary Should Contain Key    ${notification}    data
    Should Not Be Empty    ${notification}[data]    Notification data should not be empty
    Should be Equal    ${entity_id}    ${notification}[data][0][id]
    Should be Equal    Eiffel Tower    ${notification}[data][0][name][value]
    Dictionary Should Contain Key    ${notification}[data][0]    almostFull
    Dictionary Should Contain Key    ${notification}[data][0]    airQualityLevel
    Dictionary Should Contain Key    ${notification}[data][0]    subCategory
Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed

lopezaguilar's avatar
lopezaguilar committed
046_08_02 Check that a notification is sent with all attributes in simplified format
    [Documentation]    The structure of the notification message shall be as mandated by clause 5.3.1. The absence of the notification.attributes member of a Subscription means that all Entity Attributes shall be included    If the notification.format member value is "keyValues" then a simplified representation of the entities (as mandated by clause 4.5.3) shall be provided
    [Tags]    sub-notification    5_8_6
    [Setup]    Setup Initial Subscriptions    ${True}
    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    ${notification}    ${headers}=    Wait for notification    ${5}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Dictionary Should Contain Key    ${notification}    data
    Should Not Be Empty    ${notification}[data]    Notification data should not be empty
    Should be Equal    ${entity_id}    ${notification}[data][0][id]
    Should be Equal    Eiffel Tower    ${notification}[data][0][name]
Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed

lopezaguilar's avatar
lopezaguilar committed
    Start Local Server    ${notification_server_host}    ${notification_server_port}

Setup Initial Subscriptions
lopezaguilar's avatar
lopezaguilar committed
    [Arguments]    ${change_json}
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
lopezaguilar's avatar
lopezaguilar committed
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    ${subscription_payload}=    Load Subscription Sample With Reachable Endpoint
    ...    ${subscription_payload_file_path}
    ...    ${subscription_id}
    ...    ${notification_server_send_url}

lopezaguilar's avatar
lopezaguilar committed
    IF    "${change_json}" == "${True}"
        ${subscription_payload}=    Update Value To JSON
        ...    ${subscription_payload}
        ...    $..notification['format']
        ...    keyValues
    END
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

lopezaguilar's avatar
lopezaguilar committed
    ${subscription_payload}=    Set Entity Id In Subscription    ${subscription_payload}    ${entity_id}
    Set Test Variable    ${entity_id}
    Set Test Variable    ${subscription_id}
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

lopezaguilar's avatar
lopezaguilar committed
    Create Entity    ${entity_building_filepath}    ${entity_id}
    Sleep    1s
    Create Subscription From Subscription Payload    ${subscription_payload}    ${CONTENT_TYPE_LD_JSON}
    Sleep    1s
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

lopezaguilar's avatar
lopezaguilar committed
After Test
    Delete Subscription    ${subscription_id}
    Delete Entity by Id    ${entity_id}