Unverified Commit 3a2434bb authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat: add TCs for showChanges in subscriptions

parent bf4684cb
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a notification is sent with changes when an attribute is updated

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/NotificationUtils.resource
Resource            ${EXECDIR}/resources/SubscriptionUtils.resource

Test Setup          Create Initial Subscription And Entity
Test Teardown       Delete Initial Subscription And Entity
Test Template       Update Attribute And Check Previous Value In Notification


*** Variables ***
${subscription_payload_file_path}=      subscriptions/subscription-building-entities-show-changes.jsonld
${building_filename}=                   building-different-attributes-types.jsonld


*** Test Cases ***    FRAGMENT_FILENAME    EXPECTATION_FILENAME
046_31_01 Show Changes For An Update Of Property
    [Tags]    sub-notification    5_8_6    show_changes    since_v1.6.1
    name-fragment.jsonld    entity-different-attributes-types-previous-property.json
046_31_02 Show Changes For An Update Of Relationship
    [Tags]    sub-notification    5_8_6    show_changes    since_v1.6.1
    locatedAt-fragment.jsonld    entity-different-attributes-types-previous-relationship.json
046_31_03 Show Changes For An Update Of GeoProperty
    [Tags]    sub-notification    5_8_6    show_changes    since_v1.6.1
    location-fragment.jsonld    entity-different-attributes-types-previous-geoproperty.json
046_31_04 Show Changes For An Update Of LanguageProperty
    [Tags]    sub-notification    5_8_6    4_5_18    show_changes    since_v1.6.1
    street-language-property-fragment.jsonld    entity-different-attributes-types-previous-language-property.json


*** Keywords ***
Update Attribute And Check Previous Value In Notification
    [Documentation]    Update an attribute in entity and check the notification contains the previous value
    [Arguments]    ${fragment_filename}    ${expectation_filename}

    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    204    ${response.status_code}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Check Notification Containing Entities Elements
    ...    ${expectation_filename}
    ...    ${notification}

Create Initial Subscription And Entity
    Create Subscription And Entity    ${subscription_payload_file_path}    ${building_filename}    046_31
    Start Local Server    ${notification_server_host}    ${notification_server_port}

Delete Initial Subscription And Entity
    Delete Subscription    ${subscription_id}
    Delete Entity by Id    ${entity_id}
    Stop Local Server
+45 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a notification is sent with changes when a JsonProperty is updated

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/NotificationUtils.resource
Resource            ${EXECDIR}/resources/SubscriptionUtils.resource

Test Setup          Create Initial Subscription And Entity
Test Teardown       Delete Initial Subscription And Entity


*** Variables ***
${subscription_payload_file_path}=      subscriptions/subscription-building-entities-show-changes.jsonld
${building_filename}=                   building-json-property-object.jsonld
${fragment_filename}=                   json-property-fragment.jsonld
${expectation_filename}=                building-previous-json-property.json


*** Test Cases ***
046_32_01 Update Json Property And Check Previous Value In Notification
    [Documentation]    Update the JsonProperty in the entity and check the notification contains the previous value
    [Tags]    sub-notification    5_8_6    4_5_24    show_changes    since_v1.6.1

    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    204    ${response.status_code}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Check Notification Containing Entities Elements
    ...    ${expectation_filename}
    ...    ${notification}


*** Keywords ***
Create Initial Subscription And Entity
    Create Subscription And Entity    ${subscription_payload_file_path}    ${building_filename}    046_32
    Start Local Server    ${notification_server_host}    ${notification_server_port}

Delete Initial Subscription And Entity
    Delete Subscription    ${subscription_id}
    Delete Entity by Id    ${entity_id}
    Stop Local Server
+45 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a notification is sent with changes when a VocabProperty is updated

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/NotificationUtils.resource
Resource            ${EXECDIR}/resources/SubscriptionUtils.resource

Test Setup          Create Initial Subscription And Entity
Test Teardown       Delete Initial Subscription And Entity


*** Variables ***
${subscription_payload_file_path}=      subscriptions/subscription-building-entities-show-changes.jsonld
${building_filename}=                   building-vocab-property-string.jsonld
${fragment_filename}=                   vocab-property-fragment.jsonld
${expectation_filename}=                building-previous-vocab-property.json


*** Test Cases ***
046_33_01 Update Vocab Property And Check Previous Value In Notification
    [Documentation]    Update the VocabProperty in the entity and check the notification contains the previous value
    [Tags]    sub-notification    5_8_6    4_5_20    show_changes    since_v1.6.1

    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    204    ${response.status_code}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Check Notification Containing Entities Elements
    ...    ${expectation_filename}
    ...    ${notification}


*** Keywords ***
Create Initial Subscription And Entity
    Create Subscription And Entity    ${subscription_payload_file_path}    ${building_filename}    046_33
    Start Local Server    ${notification_server_host}    ${notification_server_port}

Delete Initial Subscription And Entity
    Delete Subscription    ${subscription_id}
    Delete Entity by Id    ${entity_id}
    Stop Local Server
+63 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a notification is sent with changes (previous value) when an attribute is deleted
...                 and showChanges is true in the subscription

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/NotificationUtils.resource
Resource            ${EXECDIR}/resources/SubscriptionUtils.resource

Test Setup          Create Initial Subscription And Entity
Test Teardown       Delete Initial Subscription And Entity
Test Template       Delete Attribute And Check Previous Value In Notification


*** Variables ***
${subscription_payload_file_path}=      subscriptions/subscription-building-entities-show-changes-attributeDeleted.jsonld
${building_filename}=                   building-different-attributes-types.jsonld


*** Test Cases ***    ATTRIBUTE_NAME    EXPECTATION_FILENAME
046_34_01 Show Changes For Deletion Of Property
    [Tags]    sub-notification    5_8_6    show_changes    since_v1.6.1
    name    entity-different-attributes-types-deleted-property.json
046_34_02 Show Changes For Deletion Of Relationship
    [Tags]    sub-notification    5_8_6    show_changes    since_v1.6.1
    locatedAt    entity-different-attributes-types-deleted-relationship.json
046_34_03 Show Changes For Deletion Of GeoProperty
    [Tags]    sub-notification    5_8_6    show_changes    since_v1.6.1
    location    entity-different-attributes-types-deleted-geoproperty.json
046_34_04 Show Changes For Deletion Of LanguageProperty
    [Tags]    sub-notification    5_8_6    4_5_18    show_changes    since_v1.6.1
    street    entity-different-attributes-types-deleted-language-property.json


*** Keywords ***
Delete Attribute And Check Previous Value In Notification
    [Documentation]    Delete an attribute from entity and check the notification contains the previous value
    [Arguments]    ${attribute_name}    ${expectation_filename}

    ${response}=    Delete Entity Attributes
    ...    entityId=${entity_id}
    ...    attributeId=${attribute_name}
    ...    datasetId=${EMPTY}
    ...    deleteAll=false
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Check Notification Containing Entities Elements
    ...    ${expectation_filename}
    ...    ${notification}

Create Initial Subscription And Entity
    Create Subscription And Entity    ${subscription_payload_file_path}    ${building_filename}    046_34
    Start Local Server    ${notification_server_host}    ${notification_server_port}

Delete Initial Subscription And Entity
    Delete Subscription    ${subscription_id}
    Delete Entity by Id    ${entity_id}
    Stop Local Server
+50 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a notification is sent with changes (previous value) when a JsonProperty is deleted
...                 and showChanges is true in the subscription

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/NotificationUtils.resource
Resource            ${EXECDIR}/resources/SubscriptionUtils.resource

Test Setup          Create Initial Subscription And Entity
Test Teardown       Delete Initial Subscription And Entity


*** Variables ***
${subscription_payload_file_path}=      subscriptions/subscription-building-entities-show-changes-attributeDeleted.jsonld
${building_filename}=                   building-json-property-object.jsonld
${expectation_filename}=                building-deleted-json-property.json


*** Test Cases ***
046_35_01 Delete Attribute And Check Previous Value In Notification
    [Documentation]    Delete a JsonProperty from entity and check the notification contains the previous value
    [Tags]    sub-notification    5_8_6    4_5_24    show_changes    since_v1.6.1

    ${response}=    Delete Entity Attributes
    ...    entityId=${entity_id}
    ...    attributeId=jsonProperty
    ...    datasetId=${EMPTY}
    ...    deleteAll=false
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    Should be Equal    ${subscription_id}    ${notification}[subscriptionId]
    Check Notification Containing Entities Elements
    ...    ${expectation_filename}
    ...    ${notification}


*** Keywords ***
Create Initial Subscription And Entity
    Create Subscription And Entity    ${subscription_payload_file_path}    ${building_filename}    046_35
    Start Local Server    ${notification_server_host}    ${notification_server_port}

Delete Initial Subscription And Entity
    Delete Subscription    ${subscription_id}
    Delete Entity by Id    ${entity_id}
    Stop Local Server
Loading