Skip to content
046_10.robot 2.8 KiB
Newer Older
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed
*** Settings ***
Documentation       The Notification content shall be JSON by default.
Arnaud Van der Poorten's avatar
Arnaud Van der Poorten 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
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-default.jsonld
${building_id_prefix}                   urn:ngsi-ld:Building:
${entity_building_filepath}             building-simple-attributes-sample.jsonld
${fragment_filename}                    airQualityLevel-fragment.jsonld
${notification_server_send_url}         http://${notification_server_host}:${notification_server_port}/notify
${expected_header_links}                <${ngsild_test_suite_context}>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"


*** Test Cases ***
046_10_01 Check that the notification is sent as JSON
    [Documentation]    The Notification shall be sent as JSON
    [Tags]    sub-notification    5_8_6
lopezaguilar's avatar
lopezaguilar committed
    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    ${notification}    ${headers}=    Wait for notification    timeout=${10}
    Dictionary Should Contain Item    ${headers}    Link    ${expected_header_links}
    Dictionary Should Not Contain Key    ${notification}[data][0]    @context

Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

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

Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed
Setup Initial Subscriptions
    ${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}
Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed
    ${subscription_payload}=    Set Entity Id In Subscription    ${subscription_payload}    ${entity_id}
    Set Suite Variable    ${subscription_id}
lopezaguilar's avatar
lopezaguilar committed
    Set Suite Variable    ${entity_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

Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed
After Test
    Delete Initial Subscriptions
    Delete Initial Entity
    Stop Local Server
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

lopezaguilar's avatar
lopezaguilar committed
Delete Initial Subscriptions
    Delete Subscription    ${subscription_id}
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

Arnaud Van der Poorten's avatar
Arnaud Van der Poorten committed
Delete Initial Entity
    Delete Entity by Id    ${entity_id}