Skip to content
046_12.robot 3.58 KiB
Newer Older
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed
*** Settings ***
Documentation       A Notification shall be sent (as mandated by each concrete binding and including any optional endpoint.info defined by clause 5.2.22) to the endpoint specified by the endpoint.uri member of the notification structure defined by clause 5.2.14
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
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

Suite Setup         Before Test
Suite 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:
${entity_building_filepath}=            building-simple-attributes-sample.jsonld
${fragment_filename}=                   airQualityLevel-fragment.jsonld
lopezaguilar's avatar
lopezaguilar committed
${notification_server_send_url}=        http://${notification_server_host}:${notification_server_port}/notify
*** Test Cases ***
lopezaguilar's avatar
lopezaguilar committed
046_12_01 Check that lastNotification is updated
    [Documentation]    The status, lastNotification and lastSuccess members shall be updated with expected value and dates. This test will check these formats.
    [Tags]    sub-notification    5_8_6
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

    Add Initial Entity
    Setup Initial Subscriptions
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}

    Wait for notification    timeout=${10}
poujol's avatar
poujol committed
    ${response}=    Retrieve Subscription
lopezaguilar's avatar
lopezaguilar committed
    ...    id=${subscription_id}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ...    context=${ngsild_test_suite_context}

poujol's avatar
poujol committed
    ${notification_info}=    Get Value From Json    ${response.json()}    $.notification

    Dictionary Should Contain Key    ${notification_info}[0]    status
    Should be Equal    ok    ${notification_info}[0][status]

    Dictionary Should Contain Key    ${notification_info}[0]    lastNotification
lopezaguilar's avatar
lopezaguilar committed
    ${last_notification_date}=    Parse Ngsild Date    ${notification_info}[0][lastNotification]
    Should Not Be Equal    ${last_notification_date}    ${None}
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

    Dictionary Should Contain Key    ${notification_info}[0]    lastSuccess
lopezaguilar's avatar
lopezaguilar committed
    ${last_success_date}=    Parse Ngsild Date    ${notification_info}[0][lastSuccess]
    Should Not Be Equal    ${last_success_date}    ${None}
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed


*** Keywords ***
Setup Initial Subscriptions
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${subscription_payload}=    Load Subscription Sample With Reachable Endpoint
    ...    ${subscription_payload_file_path}
    ...    ${subscription_id}
    ...    ${notification_server_send_url}
    ${subscription_payload}=    Set Entity Id In Subscription    ${subscription_payload}    ${entity_id}
    Create Subscription From Subscription Payload    ${subscription_payload}    ${CONTENT_TYPE_LD_JSON}
    Set Suite Variable    ${subscription_id}

Delete Initial Subscriptions
    Delete Subscription    ${subscription_id}

Before Test
poujol's avatar
poujol committed
    Start Local Server    ${notification_server_host}    ${notification_server_port}

After Test
    Delete Initial Subscriptions
    Delete Initial Entity
    Stop Local Server

Add Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Create Entity    ${entity_building_filepath}    ${entity_id}
    Set Suite Variable    ${entity_id}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}