Commit f2deb089 authored by Houcem Kacem's avatar Houcem Kacem
Browse files

feat: add tps for retrieve context source registration subscription

parent 53a0380a
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can retrieve a context source registration subscription
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

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

*** Variable ***
${subscription_id_prefix}=  urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=   csourceSubscriptions/subscription-sample.jsonld

*** Test Case ***
Retrieve Context Source Registration Subscription
    [Documentation]  Check that you can retrieve a context source registration subscription
    [Tags]  mandatory

    Retrieve Context Source Registration Subscription  ${subscription_id}   context=${ngsild_test_suite_context}

    Check Response Status Code Set To  200
    Check Response Body Containing Subscription element     ${subscription_payload_file_path}   ${subscription_id}

*** 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}
+16 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot retrieve a context source registration subscription with an invalid URI, an error of type BadRequestData shall be raised
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Test Case ***
Retrieve Context Source Registration Subscription With An Invalid Id
    [Documentation]  Check that you cannot retrieve a context source registration subscription with an invalid URI, an error of type BadRequestData shall be raised
    [Tags]  mandatory

    Retrieve Context Source Registration Subscription  invalidUri

    Check Response Status Code Set To  400
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}
+16 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot retrieve an unknown context source registration subscription, an error of type ResourceNotFound shall be raised
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Test Case ***
Retrieve Unknown Context Source Registration Subscription
    [Documentation]  Check that you cannot retrieve an unknown context source registration subscription, an error of type ResourceNotFound shall be raised
    [Tags]  mandatory

    Retrieve Context Source Registration Subscription  urn:ngsi-ld:Subscription:unknowSubscription

    Check Response Status Code Set To  404
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_RESOURCE_NOT_FOUND}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}
+2 −2
Original line number Diff line number Diff line
@@ -4,8 +4,8 @@ def compare_dictionaries_ignoring_keys(dict1, dict2, exclude_regex_paths):
    """Function exposed as a keyword to compare two dictionaries
    :param dict1: actual dictionary
    :param dict2: expected dictionary
    :param exclude_regex_paths: regex path of keys to be ignored
    :param exclude_regex_paths: list of regex paths of keys to be ignored
    """
    res = DeepDiff(dict1, dict2, exclude_regex_paths=[exclude_regex_paths], ignore_order=True)
    res = DeepDiff(dict1, dict2, exclude_regex_paths=exclude_regex_paths, ignore_order=True)
    print(res)
    return not res
+4 −2
Original line number Diff line number Diff line
@@ -410,9 +410,11 @@ Update Context Source Registration Subscription
    Set Test Variable  ${response}

Retrieve Context Source Registration Subscription
    [Arguments]  ${subscription_id}
    [Arguments]  ${subscription_id}     ${context}=${EMPTY}

    ${response}=  GET  ${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH}/${subscription_id}
    &{headers}=  Create Dictionary
    Run Keyword If     '${context}'!=''       Set To Dictionary   ${headers}    Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json"
    ${response}=  GET  ${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH}/${subscription_id}     headers=${headers}
    Output  request
    Output  response

Loading