Commit d56b0681 authored by kzangeli's avatar kzangeli Committed by Ken Zangelin
Browse files

fix: ignore NotificationParams Additional Members in subscription config TCs

A subscription's notification object carries Additional Members (5.2.14.2) —
lastNotification/lastSuccess/lastFailure/timesSent/timesFailed and the
last-result status — populated only after a notification has been delivered,
so they are non-deterministic in create/update/retrieve/query TCs. Exclude
them via a new notification-scoped regex var (notification_result_regex_expr),
matching the existing Additional-Members convention used in 038/040. The regex
is scoped to the notification object, so subscription-level status and
notificationTrigger stay verified. Also fixes the double-quoted ignore-key
regexes in the subscription-list keyword that never matched DeepDiff's paths.
parent 46e7de31
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -29,7 +29,10 @@ ${subscription_expectation_file_path}= subscriptions/expectations/subscript
    ...    id=${subscription_id}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ...    context=${ngsild_test_suite_context}
    ${ignore_keys}=    Create List    jsonldContext    timesFailed    timesSent    notificationTrigger
    # Ignore the broker-computed Additional Members of NotificationParams (lastNotification/
    # lastSuccess/lastFailure/timesSent/timesFailed/status) — non-deterministic, present
    # only after a notification has been delivered.
    ${ignore_keys}=    Create List    jsonldContext    notificationTrigger    ${notification_result_regex_expr}
    Check Created Resource Set To    ${expected_subscription}    ${response1.json()}    ${ignore_keys}


+4 −1
Original line number Diff line number Diff line
@@ -23,7 +23,10 @@ ${expectation_file_path}= subscriptions/expectations/subscriptions
    ...    id=${subscription_id}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}
    ${ignore_keys}=    Create List    jsonldContext    timesFailed    timesSent    notificationTrigger
    # Ignore the broker-computed Additional Members of NotificationParams (lastNotification/
    # lastSuccess/lastFailure/timesSent/timesFailed/status) — non-deterministic, present
    # only after a notification has been delivered.
    ${ignore_keys}=    Create List    jsonldContext    notificationTrigger    ${notification_result_regex_expr}
    Check Response Body Containing Subscription element
    ...    ${expectation_file_path}
    ...    ${subscription_id}
+8 −2
Original line number Diff line number Diff line
@@ -31,7 +31,10 @@ ${expected_expanded_subscription_payload_file_path}= subscriptions/expectatio
    ${response1}=    Retrieve Subscription
    ...    id=${subscription_id}
    ...    context=${ngsild_test_suite_context}
    ${ignore_keys}=    Create List    jsonldContext    timesFailed    timesSent    notificationTrigger
    # Ignore the broker-computed Additional Members of NotificationParams (lastNotification/
    # lastSuccess/lastFailure/timesSent/timesFailed/status) — non-deterministic, present
    # only after a notification has been delivered.
    ${ignore_keys}=    Create List    jsonldContext    notificationTrigger    ${notification_result_regex_expr}
    Check Response Body Containing Subscription element
    ...    ${expected_subscription_payload_file_path}
    ...    ${subscription_id}
@@ -50,7 +53,10 @@ ${expected_expanded_subscription_payload_file_path}= subscriptions/expectatio
    Check Response Body Is Empty    ${response}
    ${response1}=    Retrieve Subscription
    ...    id=${subscription_id}
    ${ignore_keys}=    Create List    jsonldContext    timesFailed    timesSent    notificationTrigger
    # Ignore the broker-computed Additional Members of NotificationParams (lastNotification/
    # lastSuccess/lastFailure/timesSent/timesFailed/status) — non-deterministic, present
    # only after a notification has been delivered.
    ${ignore_keys}=    Create List    jsonldContext    notificationTrigger    ${notification_result_regex_expr}
    Check Response Body Containing Subscription element
    ...    ${expected_expanded_subscription_payload_file_path}
    ...    ${subscription_id}
+4 −2
Original line number Diff line number Diff line
@@ -32,12 +32,14 @@ ${subscription_update_fragment_file_path}= subscriptions/fragments/subscrip
    ...    id=${subscription_id}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ...    context=${ngsild_test_suite_context}
    # Ignore the broker-computed Additional Members of NotificationParams (lastNotification/
    # lastSuccess/lastFailure/timesSent/timesFailed/status) — non-deterministic, present
    # only after a notification has been delivered.
    ${ignored_attributes}=    Create List
    ...    ${status_regex_expr}
    ...    jsonldContext
    ...    timesFailed
    ...    timesSent
    ...    notificationTrigger
    ...    ${notification_result_regex_expr}
    Check Updated Resource Set To
    ...    updated_resource=${subscription}
    ...    response_body=${response1.json()}
+11 −4
Original line number Diff line number Diff line
@@ -21,6 +21,10 @@ ${timesFailed_regex_expr}= root\\['timesFailed'\\]
${timesSent_regex_expr}=                    root\\['timesSent'\\]
${is_active_expr}=                          root\\['isActive'\\]
${context_source_ignored_regex_expr}=       root\\['@context'\\]
# Broker-computed Additional Members of NotificationParams (5.2.14.2), nested under
# the Subscription's 'notification' object — non-deterministic (present only after a
# notification has been delivered), so excluded from equality checks at any index.
${notification_result_regex_expr}=          \\['notification'\\]\\['(lastNotification|lastSuccess|lastFailure|timesSent|timesFailed|status)'\\]


*** Keywords ***
@@ -268,12 +272,15 @@ Check Response Body Containing List Containing Subscription elements
        ...    ${subscription_id}
        ${index}=    Evaluate    ${index} + 1
    END
    # Ignore the broker-computed Additional Members of NotificationParams (lastNotification/
    # lastSuccess/lastFailure/timesSent/timesFailed/status) — non-deterministic, present only
    # after a notification has been delivered; the regex is scoped to the notification object
    # so the subscription-level status and notificationTrigger stay verified. (The previous
    # entries were double-quoted and never matched DeepDiff's single-quoted paths.)
    ${ignored_keys}=    Create List
    ...    ${context_regex_expr}
    ...    "jsonldContext"
    ...    "timesFailed"
    ...    "timesSent"
    ...    "notificationTrigger"
    ...    jsonldContext
    ...    ${notification_result_regex_expr}
    ${comparison_result}=    Compare Dictionaries Ignoring Keys
    ...    ${subscription_payload}
    ...    ${response_body}