Skip to content
046_13.robot 3.05 KiB
Newer Older
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed
*** Settings ***
Documentation       If the response to the notification request is different than 200 OK then implementations shall: Update notification.lastFailure with a timestamp representing the current date and time, update notification.status to "failed"

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
Resource            ${EXECDIR}/resources/MockServerUtils.resource

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


*** Test Cases ***
lopezaguilar's avatar
lopezaguilar committed
046_13_01 Check that lastFailure and status are updated if a notification could not be sent
    [Documentation]    If the response to the notification request is different than 200 OK then implementations shall: Update notification.lastFailure with a timestamp representing the current date and time, update notification.status to "failed"
    [Tags]    sub-notification    5_8_6
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

    @{expected_notification_data_entities}=    Create List    Building
    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}

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
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

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

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

Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed
*** Keywords ***
Setup Initial Subscription
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    Create Subscription    ${subscription_id}    ${subscription_payload_file_path}    ${CONTENT_TYPE_LD_JSON}
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed
    Set Suite Variable    ${subscription_id}

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

    ${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}

Before Test
    Setup Initial Subscription
    Add Initial Entity
Gert De Tant @ Sirus's avatar
Gert De Tant @ Sirus committed

After Test
    Delete Initial Subscription
    Delete Initial Entity