Skip to content
046_02.robot 3.25 KiB
Newer Older
*** Settings ***
Documentation       If a Subscription defines a timeInterval member, a Notification shall be sent periodically, when the time interval (in seconds) specified in such value field is reached, regardless of Attribute changes.

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

Suite Setup         Before Test
Suite Teardown      After Test


*** Variables ***
${subscription_id_prefix}=              urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=      subscriptions/subscription-timeInterval-sample.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


*** Test Cases ***
046_02_01 Check that a notification is sent on the timeInterval
    [Documentation]    If a Subscription defines a timeInterval member, a Notification shall be sent periodically, when the time interval (in seconds) specified in such value field is reached, regardless of Attribute changes.

    Add Initial Entity
    Sleep    1s
    Setup Initial Subscriptions

    ${notification}    ${headers}=    Wait for notification    timeout=${15}
    ${notification}    ${headers}=    Wait for notification    timeout=${15}

    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 True
    ...    '${notification}[data][0][airQualityLevel][value]'=='4.0' or '${notification}[data][0][airQualityLevel][value]'=='4'
    Should be Equal    Eiffel Tower    ${notification}[data][0][name][value]

*** 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}
Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed
    Create Subscription From Subscription Payload    ${subscription_payload}    ${CONTENT_TYPE_LD_JSON}
    Set Suite Variable    ${subscription_id}
Delete Initial Subscriptions
    Delete Subscription    ${subscription_id}
Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed
Add Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed
    Create Entity    ${entity_building_filepath}    ${entity_id}
    Set Suite Variable    ${entity_id}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}

Before Test
poujol's avatar
poujol committed
    Start Local Server    ${notification_server_host}    ${notification_server_port}
Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed

After Test
    Delete Initial Subscriptions
    Delete Initial Entity
    Stop Local Server