Skip to content
040_01.robot 3.19 KiB
Newer Older
Documentation       Check that you can retrieve a context source registration subscription

Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistrationSubscription.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Setup Initial Context Source Registration Subscription
Test Teardown       Delete Created Context Source Registration Subscription


*** Variables ***
${subscription_id_prefix}=              urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=      csourceSubscriptions/subscription-sample.jsonld
${expectation_file_path}=               csourceSubscriptions/expectations/subscriptions-040-01-expectation.json


*** Test Cases ***
lopezaguilar's avatar
lopezaguilar committed
040_01_01 Retrieve Context Source Registration Subscription
    [Documentation]    Check that you can retrieve a context source registration subscription
    [Tags]    csrsub-retrieve    5_11_4
poujol's avatar
poujol committed
    ${response}=    Retrieve Context Source Registration Subscription
lopezaguilar's avatar
lopezaguilar committed
    ...    subscription_id=${subscription_id}
poujol's avatar
poujol committed
    ...    context=${ngsild_test_suite_context}
lopezaguilar's avatar
lopezaguilar committed

    ${expected_link_header}=    CATENATE
    ...    SEPARATOR=
    ...    <
    ...    ${ngsild_test_suite_context}
    ...    >; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"

poujol's avatar
poujol committed
    Check Response Status Code    200    ${response.status_code}
lopezaguilar's avatar
lopezaguilar committed
    Check Response Reason set to    ${response.reason}    OK
    Check Response Headers Link set to
    ...    response_headers=${response.headers}
    ...    expected_link_header=${expected link header}

    ${expectation_payload}=    Load Test Sample    ${expectation_file_path}    ${subscription_id}

    # We need to ignore the Additional Members ('lastFailure', 'lastNotification', 'timesFailed', 'timesSent', 'isActive')
    ${ignored_attributes}=    Create List
    ...    ${status_regex_expr}
    ...    ${lastfailure_regex_expr}
    ...    ${lastNotification_regex_expr}
    ...    ${timesFailed_regex_expr}
    ...    ${timesSent_regex_expr}
    ...    ${is_active_expr}

    Check Created Resource Set To
    ...    created_resource=${expectation_payload}
    ...    response_body=${response.json()}
    ...    ignored_keys=${ignored_attributes}

    Check Dictionary Might Contain Additional Members of the NotificationParams    ${response.json()}    lastNotification
    Check Dictionary Might Contain Additional Members of the NotificationParams    ${response.json()}    lastFailure
    Check Dictionary Might Contain Additional Members of the NotificationParams    ${response.json()}    lastSuccess
    Check Dictionary Might Contain Additional Members of the NotificationParams    ${response.json()}    timesSent
*** Keywords ***
Setup Initial Context Source Registration Subscription
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${subscription_payload}=    Load Test Sample    ${subscription_payload_file_path}    ${subscription_id}
    Create Context Source Registration Subscription    ${subscription_payload}
    Set Suite Variable    ${subscription_id}

Delete Created Context Source Registration Subscription
    Delete Context Source Registration Subscription    ${subscription_id}