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

feat: implement test cases for update subscription

parent 406489a3
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot update a subcription: If the Subscription id is not present or it is not a valid URI, then an error of type BadRequestData shall be raised
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Test Template  Update Subscription With Non present Or Invalid Id

*** Test Cases ***          id
NotPresentId                ${EMPTY}
InvalidId                   InvalidUri

*** Variable ***
${subscription_update_fragment_file_path}=   subscriptions/fragments/subscription-update-sample.json

*** Keywords ***
Update Subscription With Non present Or Invalid Id
    [Arguments]  ${id}
    [Documentation]  Check that you cannot update a subcription: If the Subscription id is not present or it is not a valid URI, then an error of type BadRequestData shall be raised
    [Tags]  mandatory

    Update Subscription   ${id}     ${subscription_update_fragment_file_path}   ${CONTENT_TYPE_JSON}

    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}
+19 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot update a subscription: If the NGSI-LD System does not know about the target Subscription, because there is no existing Subscription whose id (URI) is equivalent, an error of type ResourceNotFound shall be raised
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${subscription_update_fragment_file_path}=   subscriptions/fragments/subscription-update-sample.json

*** Test Case ***
Update Unknown Subscription
    [Documentation]  Check that you cannot update a subscription: If the NGSI-LD System does not know about the target Subscription, because there is no existing Subscription whose id (URI) is equivalent, an error of type ResourceNotFound shall be raised
    [Tags]  mandatory

    Update Subscription   unknownSubscription     ${subscription_update_fragment_file_path}   ${CONTENT_TYPE_JSON}

    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}
+35 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot update a subcription: If the data types and restriction are not met by the Subscription Fragment, then an error of type BadRequestData shall be raised
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Suite Setup      Setup Initial Subscriptions
Suite Teardown      Delete Initial Subscriptions

*** Variable ***
${subscription_id_prefix}=  urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=   subscriptions/subscription-sample.jsonld
${subscription_update_fragment_file_path}=   subscriptions/fragments/subscription-invalid-update-sample.json

*** Test Case ***
Update Subscription With Invalid Fragment
    [Documentation]  Check that you cannot update a subcription: If the data types and restriction are not met by the Subscription Fragment, then an error of type BadRequestData shall be raised
    [Tags]  mandatory

    Update Subscription   ${subscription_id}     ${subscription_update_fragment_file_path}   ${CONTENT_TYPE_JSON}

    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}

*** Keywords ***
Setup Initial Subscriptions
    ${subscription_id}=     Generate Random Entity Id    ${subscription_id_prefix}

    Create Subscription  ${subscription_id}     ${subscription_payload_file_path}   ${CONTENT_TYPE_LD_JSON}

    Set Suite Variable  ${subscription_id}

Delete Initial Subscriptions
    Delete Subscription     ${subscription_id}
+35 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot update a subscription: Any attempt to remove (by setting them to null in the Fragment) mandatory properties of a Subscription (clause 5.2.12) shall result in an error of type BadRequestData
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Suite Setup      Setup Initial Subscriptions
Suite Teardown      Delete Initial Subscriptions

*** Variable ***
${subscription_id_prefix}=  urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=   subscriptions/subscription-sample.jsonld
${subscription_update_fragment_file_path}=   subscriptions/fragments/subscription-null-properties-update-sample.json

*** Test Case ***
Update Subscription With Null Mandatory Properties
    [Documentation]  Check that you cannot update a subscription: Any attempt to remove (by setting them to null in the Fragment) mandatory properties of a Subscription (clause 5.2.12) shall result in an error of type BadRequestData
    [Tags]  mandatory

    Update Subscription   ${subscription_id}     ${subscription_update_fragment_file_path}   ${CONTENT_TYPE_JSON}

    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}

*** Keywords ***
Setup Initial Subscriptions
    ${subscription_id}=     Generate Random Entity Id    ${subscription_id_prefix}

    Create Subscription  ${subscription_id}     ${subscription_payload_file_path}   ${CONTENT_TYPE_LD_JSON}

    Set Suite Variable  ${subscription_id}

Delete Initial Subscriptions
    Delete Subscription     ${subscription_id}
+41 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can update a subcription: Term to URI expansion of Attribute names shall be observed
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Suite Setup      Setup Initial Subscriptions
Suite Teardown      Delete Initial Subscriptions

*** Variable ***
${subscription_id_prefix}=  urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=   subscriptions/subscription-sample.jsonld
${subscription_update_fragment_file_path}=   subscriptions/fragments/subscription-vehicle-entities-sample.json
${expected_subscription_payload_file_path}=   subscriptions/expected/subscription-vehicle-sample.jsonld
${expected_expanded_subscription_payload_file_path}=   subscriptions/expected/subscription-vehicle-expanded-types-sample.jsonld

*** Test Case ***
Update Subscription With Term to Uri Expansion
    [Documentation]  Check that you can update a subcription: Term to URI expansion of Attribute names shall be observed
    [Tags]  mandatory

    Update Subscription   ${subscription_id}     ${subscription_update_fragment_file_path}   ${CONTENT_TYPE_JSON}   context=${ngsild_test_suite_context}

    Check Response Status Code Set To  204

    Retrieve Subscription   ${subscription_id}  context=${ngsild_test_suite_context}
    Check Response Body Containing Subscription element     ${expected_subscription_payload_file_path}   ${subscription_id}

    Retrieve Subscription   ${subscription_id}
    Check Response Body Containing Subscription element     ${expected_expanded_subscription_payload_file_path}   ${subscription_id}

*** Keywords ***
Setup Initial Subscriptions
    ${subscription_id}=     Generate Random Entity Id    ${subscription_id_prefix}

    Create Subscription  ${subscription_id}     ${subscription_payload_file_path}   ${CONTENT_TYPE_LD_JSON}

    Set Suite Variable  ${subscription_id}

Delete Initial Subscriptions
    Delete Subscription     ${subscription_id}
Loading