From 1b4ea525dad1972d2f40596701cc8d7eacaba422 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Thu, 28 Sep 2023 17:17:47 +0200 Subject: [PATCH 1/3] fix(046_01-09): mainly incorrect implementations --- .../046_02.robot | 2 +- .../046_03.robot | 7 +++++-- .../046_04.robot | 2 +- .../046_05.robot | 4 ++-- .../046_06.robot | 4 ++-- .../046_07.robot | 15 ++++++--------- .../046_09.robot | 15 ++++++++------- ...building-entities-active-endpoint-info.jsonld} | 7 +++++-- ...cription-building-entities-active-query.jsonld | 1 - libraries/assertionUtils.py | 8 +++----- resources/NotificationUtils.resource | 4 +++- 11 files changed, 36 insertions(+), 33 deletions(-) rename data/subscriptions/{subscription-timeInterval-sample-query.jsonld => subscription-building-entities-active-endpoint-info.jsonld} (70%) diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_02.robot index dacc53db..6c8fcbce 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_02.robot @@ -13,7 +13,7 @@ Suite Teardown After Test *** Variables *** ${subscription_id_prefix}= urn:ngsi-ld:Subscription: -${subscription_payload_file_path}= subscriptions/subscription-timeInterval-sample-query.jsonld +${subscription_payload_file_path}= subscriptions/subscription-timeInterval-sample.jsonld ${building_id_prefix}= urn:ngsi-ld:Building: ${notification_server_send_url}= http://${notification_server_host}:${notification_server_port}/notify ${entity_building_filepath}= building-simple-attributes-sample.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_03.robot index 11aacaea..3a1c93cf 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_03.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_03.robot @@ -13,10 +13,11 @@ Suite Teardown After Test *** Variables *** ${subscription_id_prefix}= urn:ngsi-ld:Subscription: -${subscription_payload_file_path}= subscriptions/subscription-timeInterval-sample.jsonld +${subscription_payload_file_path}= subscriptions/subscription-building-entities-default.jsonld ${building_id_prefix}= urn:ngsi-ld:Building: ${notification_server_send_url}= http://${notification_server_host}:${notification_server_port}/notify ${entity_building_filepath}= building-simple-attributes-sample.jsonld +${fragment_filename}= airQualityLevel-fragment.jsonld *** Test Cases *** @@ -28,13 +29,15 @@ ${entity_building_filepath}= building-simple-attributes-sample.jsonld Sleep 1s Setup Initial Subscriptions + Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + ${notification}= Wait for notification ${5} Should be Equal ${subscription_id} ${notification}[subscriptionId] Dictionary Should Contain Key ${notification} data Should Not Be Empty ${notification}[data] Notification data should not be empty Should be Equal ${entity_id} ${notification}[data][0][id] Should be True - ... '${notification}[data][0][airQualityLevel][value]'=='4.0' or '${notification}[data][0][airQualityLevel][value]'=='4' + ... '${notification}[data][0][airQualityLevel][value]'=='5.0' or '${notification}[data][0][airQualityLevel][value]'=='5' Should be Equal Eiffel Tower ${notification}[data][0][name][value] diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_04.robot index 8a28883c..32beee5e 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_04.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_04.robot @@ -13,7 +13,7 @@ Suite Teardown After Test *** Variables *** ${subscription_id_prefix}= urn:ngsi-ld:Subscription: -${subscription_payload_file_path}= subscriptions/subscription-building-entities-active-watchedAttributes-query.jsonld +${subscription_payload_file_path}= subscriptions/subscription-building-entities-active-watchedAttributes.jsonld ${building_id_prefix}= urn:ngsi-ld:Building: ${notification_server_send_url}= http://${notification_server_host}:${notification_server_port}/notify ${entity_building_filepath}= building-simple-attributes-sample.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_05.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_05.robot index ddd662ed..b17ad805 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_05.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_05.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation If a Subscription does not define a timeInterval member, the notification shall be sent whenever there is a change in the watched Attributes. The notification message shall include all the subscribed Entities that changed and that match (as mandated by clauses 4.9 and 4.10) the query and geoquery conditions +Documentation If a Subscription does not define a timeInterval member, the notification shall be sent whenever there is a change in the watched Attributes and the entity matches the q parameter. The notification message shall include all the subscribed Entities that changed and that match (as mandated by clauses 4.9 and 4.10) the query and geoquery conditions Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource @@ -13,7 +13,7 @@ Suite Teardown After Test *** Variables *** ${subscription_id_prefix}= urn:ngsi-ld:Subscription: -${subscription_payload_file_path}= subscriptions/subscription-building-entities-active-watchedAttributes.jsonld +${subscription_payload_file_path}= subscriptions/subscription-building-entities-active-watchedAttributes-query.jsonld ${building_id_prefix}= urn:ngsi-ld:Building: ${notification_server_send_url}= http://${notification_server_host}:${notification_server_port}/notify ${entity_building_filepath}= building-simple-attributes-sample.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_06.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_06.robot index bed35306..007004b7 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_06.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_06.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation If a Subscription does not define a timeInterval member, the notification shall be sent whenever there is a change in the watched Attributes. The notification message shall include all the subscribed Entities that changed and that match (as mandated by clauses 4.9 and 4.10) the query and geoquery conditions +Documentation If a Subscription does not define a timeInterval member, the notification shall be sent whenever an entity matches the query defined in the subscription. The notification message shall include all the subscribed Entities that changed and that match (as mandated by clauses 4.9 and 4.10) the query and geoquery conditions Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource @@ -21,7 +21,7 @@ ${notification_server_send_url}= http://${notification_server_host}:${not *** Test Cases *** 046_06_01 Check that a notification is sent with all matching entities - [Documentation] only the subscribed Entities matching the query and watched attributes shall be included. + [Documentation] Only the subscribed Entities matching the query shall be included. [Tags] sub-notification 5_8_6 046_06 ${entity_building}= Create Entity Selecting Content Type ... ${building_filename} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot index 0f88bd87..54ebf412 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot @@ -36,9 +36,8 @@ ${date_format_with_millis} %Y-%m-%dT%H:%M:%S.%fZ ${notification}= Wait for notification Should Be Equal ${notification}[type] Notification Should Be Equal ${notification}[subscriptionId] ${subscription_id} - ${is_date}= Is Date ${notification}[notifiedAt] ${date_format} - ${is_date_with_millis}= Is Date ${notification}[notifiedAt] ${date_format_with_millis} - Should Be True ${is_date} or ${is_date_with_millis} + ${notified_at_date}= Parse Ngsild Date ${notification}[notifiedAt] + Should Not Be Equal ${notified_at_date} ${None} [Teardown] Delete Fixture Data 046_07_02 Check correct attributes are included @@ -52,9 +51,8 @@ ${date_format_with_millis} %Y-%m-%dT%H:%M:%S.%fZ ${notification}= Wait for notification Should Be Equal ${notification}[type] Notification Should Be Equal ${notification}[subscriptionId] ${subscription_id} - ${is_date}= Is Date ${notification}[notifiedAt] ${date_format} - ${is_date_with_millis}= Is Date ${notification}[notifiedAt] ${date_format_with_millis} - Should Be True ${is_date} or ${is_date_with_millis} + ${notified_at_date}= Parse Ngsild Date ${notification}[notifiedAt] + Should Not Be Equal ${notified_at_date} ${None} Dictionary Should Contain Key ${notification}[data][0] airQualityLevel [Teardown] Delete Fixture Data @@ -69,9 +67,8 @@ ${date_format_with_millis} %Y-%m-%dT%H:%M:%S.%fZ ${notification}= Wait for notification Should Be Equal ${notification}[type] Notification Should Be Equal ${notification}[subscriptionId] ${subscription_id} - ${is_date}= Is Date ${notification}[notifiedAt] ${date_format} - ${is_date_with_millis}= Is Date ${notification}[notifiedAt] ${date_format_with_millis} - Should Be True ${is_date} or ${is_date_with_millis} + ${notified_at_date}= Parse Ngsild Date ${notification}[notifiedAt] + Should Not Be Equal ${notified_at_date} ${None} Dictionary Should Contain Key ${notification}[data][0] https://ngsi-ld-test-suite/context#airQualityLevel [Teardown] Delete Fixture Data diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_09.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_09.robot index 0c6c624b..4478fa41 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_09.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_09.robot @@ -12,12 +12,12 @@ Suite Teardown After Test *** Variables *** -${subscription_id_prefix}= urn:ngsi-ld:Subscription: -${subscription_payload_file_path}= subscriptions/subscription-building-entities-active.jsonld -${building_id_prefix}= urn:ngsi-ld:Building: -${entity_building_filepath}= building-simple-attributes-sample.jsonld -${fragment_filename}= airQualityLevel-fragment.jsonld -${notification_server_send_url}= http://${notification_server_host}:${notification_server_port}/notify +${subscription_id_prefix} urn:ngsi-ld:Subscription: +${subscription_payload_file_path} subscriptions/subscription-building-entities-active-endpoint-info.jsonld +${building_id_prefix} urn:ngsi-ld:Building: +${entity_building_filepath} building-simple-attributes-sample.jsonld +${fragment_filename} airQualityLevel-fragment.jsonld +${notification_server_send_url} http://${notification_server_host}:${notification_server_port}/notify *** Test Cases *** @@ -31,7 +31,8 @@ ${notification_server_send_url}= http://${notification_server_host}:${not Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification timeout=${10} + ${notification} ${headers}= Wait for notification timeout=${10} + Dictionary Should Contain Key ${headers} X-Additional-Key *** Keywords *** diff --git a/data/subscriptions/subscription-timeInterval-sample-query.jsonld b/data/subscriptions/subscription-building-entities-active-endpoint-info.jsonld similarity index 70% rename from data/subscriptions/subscription-timeInterval-sample-query.jsonld rename to data/subscriptions/subscription-building-entities-active-endpoint-info.jsonld index a6bd1088..7e907cdb 100644 --- a/data/subscriptions/subscription-timeInterval-sample-query.jsonld +++ b/data/subscriptions/subscription-building-entities-active-endpoint-info.jsonld @@ -1,16 +1,19 @@ { "id":"urn:ngsi-ld:Subscription:randomUUID", "type":"Subscription", - "timeInterval": 10, "entities":[ { "type":"Building" } ], "notification":{ + "format": "normalized", "endpoint":{ "uri":"http://my.endpoint.org/notify", - "accept":"application/json" + "accept":"application/json", + "receiverInfo": [ + { "key": "X-Additional-Key", "value": "Value" } + ] } }, "@context":[ diff --git a/data/subscriptions/subscription-building-entities-active-query.jsonld b/data/subscriptions/subscription-building-entities-active-query.jsonld index 2cce3970..71660571 100644 --- a/data/subscriptions/subscription-building-entities-active-query.jsonld +++ b/data/subscriptions/subscription-building-entities-active-query.jsonld @@ -7,7 +7,6 @@ "type":"Building" } ], - "watchedAttributes": ["name"], "q":"name==\"Eiffel Tower\"", "notification":{ "format":"keyValues", diff --git a/libraries/assertionUtils.py b/libraries/assertionUtils.py index 6b82b539..ae9fc089 100644 --- a/libraries/assertionUtils.py +++ b/libraries/assertionUtils.py @@ -1,13 +1,11 @@ -import datetime import re from dataclasses import dataclass +import dateTimeUtils from deepdiff import DeepDiff from deepdiff.helper import CannotCompare from prettydiff import get_annotated_lines_from_diff, diff_json, Flag from robot.api import logger -from dateTimeUtils import parse_ngsild_date - @dataclass class Theme: @@ -56,8 +54,8 @@ class TemporalPropertyOperator: or level.path().endswith("['deletedAt']")) def give_up_diffing(self, level, diff_instance) -> bool: - expected_datetime = parse_ngsild_date(level.t1) - actual_datetime = parse_ngsild_date(level.t2) + expected_datetime = dateTimeUtils.parse_ngsild_date(level.t1) + actual_datetime = dateTimeUtils.parse_ngsild_date(level.t2) return actual_datetime is not None and expected_datetime == actual_datetime diff --git a/resources/NotificationUtils.resource b/resources/NotificationUtils.resource index ac978eba..c8e76545 100644 --- a/resources/NotificationUtils.resource +++ b/resources/NotificationUtils.resource @@ -31,8 +31,10 @@ Wait for notification Reply By 200 ${notification_payload}= Get Request Body + ${notification_headers}= Get Request Headers ${notification}= Evaluate json.loads('''${notification_payload}''') json - RETURN ${notification} + ${headers}= Convert To Dictionary ${notification_headers} + RETURN ${notification} ${headers} Wait for notification and validate it [Arguments] -- GitLab From b672f546728abe4b4778eb2f18a1717bf786cc18 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Thu, 28 Sep 2023 17:58:52 +0200 Subject: [PATCH 2/3] feat: add body and headers of notifications received in the logs --- libraries/logUtils.py | 18 ++++++++++++++++++ resources/NotificationUtils.resource | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libraries/logUtils.py b/libraries/logUtils.py index 9254bc59..c796a189 100644 --- a/libraries/logUtils.py +++ b/libraries/logUtils.py @@ -39,3 +39,21 @@ def output(response, description, console=True): logger.info(pretty_request_json, also_console=True) logger.info("Response ->", also_console=True) logger.info(pretty_response_json, also_console=True) + + +@keyword(name="Output Notification", tags=("I/O",)) +def output_notification(body, headers, description, console=True): + """*Body and headers of the notification are output to terminal and file (in JSON).* + :param body: body of the notification received + :param headers: headers of the notification received + :param description: explains what request is being made + :param console: If false, the JSON is not written to terminal. Default is true. + """ + + request_json = {'headers': dict(headers), 'body': body} + + pretty_request_json = dumps(request_json, indent=4, sort_keys=False, separators=(",", ": ")) + + logger.info("\n" + description, also_console=True) + logger.info("Notification ->", also_console=True) + logger.info(pretty_request_json, also_console=True) diff --git a/resources/NotificationUtils.resource b/resources/NotificationUtils.resource index c8e76545..38f546ad 100644 --- a/resources/NotificationUtils.resource +++ b/resources/NotificationUtils.resource @@ -34,6 +34,7 @@ Wait for notification ${notification_headers}= Get Request Headers ${notification}= Evaluate json.loads('''${notification_payload}''') json ${headers}= Convert To Dictionary ${notification_headers} + Output Notification ${notification} ${notification_headers} Wait for notification RETURN ${notification} ${headers} Wait for notification and validate it @@ -51,12 +52,13 @@ Wait for notification and validate it Reply By 200 ${notification_payload}= Get Request Body + ${notification_headers}= Get Request Headers ${notification}= Evaluate json.loads('''${notification_payload}''') json ${notification_data_length}= Get length ${notification}[data] ${expected_notification_data_entities_length}= Get length ${expected_notification_data_entities} ${expected_notification_data_length}= Get length ${expected_context_source_registration_ids} - log ${notification} + Output Notification ${notification} ${notification_headers} Wait for notification Should Be Equal ${notification}[type] ${notification_type} Should Be Equal ${notification}[subscriptionId] ${expected_subscription_id} ${is_date}= Is Date ${notification}[notifiedAt] ${date_format} -- GitLab From 34d129ef3ed9719d2dcc006f8f713d706b0d0d83 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Thu, 28 Sep 2023 19:12:45 +0200 Subject: [PATCH 3/3] fix: other inconsistencies in implementations wrt purpose of the tests --- .../046_01.robot | 2 +- .../046_02.robot | 4 ++-- .../046_03.robot | 2 +- .../046_04.robot | 2 +- .../046_05.robot | 2 +- .../046_06.robot | 2 +- .../046_07.robot | 6 +++--- .../046_08.robot | 4 ++-- .../046_10.robot | 16 +++++----------- .../046_12.robot | 10 ++++------ .../046_13.robot | 5 ++--- .../046_14.robot | 6 +++--- 12 files changed, 26 insertions(+), 35 deletions(-) diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_01.robot index 8240fc84..aea73282 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_01.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_01.robot @@ -32,7 +32,7 @@ ${notification_server_send_url}= http://${notification_server_host}:${not Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification timeout=${10} + ${notification} ${headers}= Wait for notification timeout=${10} Should be Equal ${subscription_id} ${notification}[subscriptionId] Should be Equal ${entity_id} ${notification}[data][0][id] diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_02.robot index 6c8fcbce..1ae54eb5 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_02.robot @@ -28,9 +28,9 @@ ${entity_building_filepath}= building-simple-attributes-sample.jsonld Sleep 1s Setup Initial Subscriptions - ${notification}= Wait for notification timeout=${15} + ${notification} ${headers}= Wait for notification timeout=${15} - ${notification}= Wait for notification timeout=${15} + ${notification} ${headers}= Wait for notification timeout=${15} Should be Equal ${subscription_id} ${notification}[subscriptionId] Dictionary Should Contain Key ${notification} data diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_03.robot index 3a1c93cf..55a3a61c 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_03.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_03.robot @@ -31,7 +31,7 @@ ${fragment_filename}= airQualityLevel-fragment.jsonld Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification ${5} + ${notification} ${headers}= Wait for notification ${5} Should be Equal ${subscription_id} ${notification}[subscriptionId] Dictionary Should Contain Key ${notification} data Should Not Be Empty ${notification}[data] Notification data should not be empty diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_04.robot index 32beee5e..c3d91068 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_04.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_04.robot @@ -30,7 +30,7 @@ ${fragment_filename}= airQualityLevel-fragment.jsonld Setup Initial Subscriptions Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification ${5} + ${notification} ${headers}= Wait for notification ${5} Should be Equal ${subscription_id} ${notification}[subscriptionId] Dictionary Should Contain Key ${notification} data Should Not Be Empty ${notification}[data] Notification data should not be empty diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_05.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_05.robot index b17ad805..53bb7484 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_05.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_05.robot @@ -30,7 +30,7 @@ ${fragment_filename}= airQualityLevel-fragment.jsonld Setup Initial Subscriptions Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification ${5} + ${notification} ${headers}= Wait for notification ${5} Should be Equal ${subscription_id} ${notification}[subscriptionId] Dictionary Should Contain Key ${notification} data Should Not Be Empty ${notification}[data] Notification data should not be empty diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_06.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_06.robot index 007004b7..7f9afb76 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_06.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_06.robot @@ -28,7 +28,7 @@ ${notification_server_send_url}= http://${notification_server_host}:${not ... ${entity_id} ... ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification timeout=${10} + ${notification} ${headers}= Wait for notification timeout=${10} Should be Equal ${subscription_id} ${notification}[subscriptionId] Should be Equal ${entity_id} ${notification}[data][0][id] diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot index 54ebf412..5893ecaa 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot @@ -33,7 +33,7 @@ ${date_format_with_millis} %Y-%m-%dT%H:%M:%S.%fZ Setup Initial Subscriptions Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification + ${notification} ${headers}= Wait for notification Should Be Equal ${notification}[type] Notification Should Be Equal ${notification}[subscriptionId] ${subscription_id} ${notified_at_date}= Parse Ngsild Date ${notification}[notifiedAt] @@ -48,7 +48,7 @@ ${date_format_with_millis} %Y-%m-%dT%H:%M:%S.%fZ Setup Initial Subscriptions ${subscription_payload_file_path_watchedAttributes} Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification + ${notification} ${headers}= Wait for notification Should Be Equal ${notification}[type] Notification Should Be Equal ${notification}[subscriptionId] ${subscription_id} ${notified_at_date}= Parse Ngsild Date ${notification}[notifiedAt] @@ -64,7 +64,7 @@ ${date_format_with_millis} %Y-%m-%dT%H:%M:%S.%fZ Setup Initial Subscriptions ${subscription_payload_file_path_default_context} Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification + ${notification} ${headers}= Wait for notification Should Be Equal ${notification}[type] Notification Should Be Equal ${notification}[subscriptionId] ${subscription_id} ${notified_at_date}= Parse Ngsild Date ${notification}[notifiedAt] diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_08.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_08.robot index ce1233da..397f05dd 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_08.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_08.robot @@ -31,7 +31,7 @@ ${fragment_filename}= airQualityLevel-fragment.jsonld Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification ${5} + ${notification} ${headers}= Wait for notification ${5} Should be Equal ${subscription_id} ${notification}[subscriptionId] Dictionary Should Contain Key ${notification} data @@ -63,7 +63,7 @@ ${fragment_filename}= airQualityLevel-fragment.jsonld Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - ${notification}= Wait for notification ${5} + ${notification} ${headers}= Wait for notification ${5} Should be Equal ${subscription_id} ${notification}[subscriptionId] Dictionary Should Contain Key ${notification} data diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_10.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_10.robot index 8de74ab1..785bc200 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_10.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_10.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation A Notification shall be sent (as mandated by each concrete binding and including any optional endpoint.info defined by clause 5.2.22) to the endpoint specified by the endpoint.uri member of the notification structure defined by clause 5.2.14 +Documentation The Notification content shall be JSON by default. Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource @@ -22,8 +22,8 @@ ${expected_header_links} <${ngsild_test_suite_context}>; rel="htt *** Test Cases *** -046_10_01 Check that a notification is JSON - [Documentation] The Notification content shall be JSON by default +046_10_01 Check that the notification is sent as JSON + [Documentation] The Notification shall be sent as JSON [Tags] sub-notification 5_8_6 046_10 Add Initial Entity @@ -32,16 +32,10 @@ ${expected_header_links} <${ngsild_test_suite_context}>; rel="htt Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - Wait For Request timeout=${10} - Reply By 200 + ${notification} ${headers}= Wait for notification timeout=${10} - ${notification_headers}= Get Request Headers - ${notification_headers_dict}= Convert To Dictionary ${notification_headers} - Dictionary Should Contain Item ${notification_headers_dict} Link ${expected_header_links} + Dictionary Should Contain Item ${headers} Link ${expected_header_links} - ${notification_payload}= Get Request Body - # json.loads parses the payload as json. It fails if the payload is malformed - ${notification}= Evaluate json.loads('''${notification_payload}''') json Dictionary Should Not Contain Key ${notification}[data][0] @context diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_12.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_12.robot index 367cc143..7dd5003d 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_12.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_12.robot @@ -44,14 +44,12 @@ ${notification_server_send_url}= http://${notification_server_host}:${not Should Be Equal ok ${notification_info}[0][status] Dictionary Should Contain Key ${notification_info}[0] lastNotification - ${is_date}= Is Date ${notification_info}[0][lastNotification] ${date_format} - ${is_date_with_millis}= Is Date ${notification_info}[0][lastNotification] ${date_format_with_millis} - Should Be True ${is_date} or ${is_date_with_millis} + ${last_notification_date}= Parse Ngsild Date ${notification_info}[0][lastNotification] + Should Not Be Equal ${last_notification_date} ${None} Dictionary Should Contain Key ${notification_info}[0] lastSuccess - ${is_date}= Is Date ${notification_info}[0][lastSuccess] ${date_format} - ${is_date_with_millis}= Is Date ${notification_info}[0][lastSuccess] ${date_format_with_millis} - Should Be True ${is_date} or ${is_date_with_millis} + ${last_success_date}= Parse Ngsild Date ${notification_info}[0][lastSuccess] + Should Not Be Equal ${last_success_date} ${None} *** Keywords *** diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_13.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_13.robot index 8ab02f20..6007a7ab 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_13.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_13.robot @@ -41,9 +41,8 @@ ${fragment_filename}= airQualityLevel-fragment.jsonld Should Be Equal failed ${notification_info}[0][status] Dictionary Should Contain Key ${notification_info}[0] lastFailure - ${is_date}= Is Date ${notification_info}[0][lastFailure] ${date_format} - ${is_date_with_millis}= Is Date ${notification_info}[0][lastFailure] ${date_format_with_millis} - Should Be True ${is_date} or ${is_date_with_millis} + ${last_failure_date}= Parse Ngsild Date ${notification_info}[0][lastFailure] + Should Not Be Equal ${last_failure_date} ${None} *** Keywords *** diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_14.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_14.robot index 210470b9..05fe6d3f 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_14.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_14.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation A Notification shall be sent (as mandated by each concrete binding and including any optional endpoint.info defined by clause 5.2.22) to the endpoint specified by the endpoint.uri member of the notification structure defined by clause 5.2.14 +Documentation The Notification content shall be JSON-LD when endpoint.accept is set to JSON-LD Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource @@ -22,7 +22,7 @@ ${notification_server_send_url} http://${notification_server_host}:${not *** Test Cases *** 046_14_01 Check that a notification is sent as JSON-LD - [Documentation] The Notification content shall be JSON-LD when we set endpoint.accept to 'application/ld+json' + [Documentation] The Notification content shall be JSON-LD when endpoint.accept is set to JSON-LD [Tags] sub-notification 5_8_6 046_14 Add Initial Entity @@ -31,7 +31,7 @@ ${notification_server_send_url} http://${notification_server_host}:${not Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} - Wait For Request timeout=${10} + Wait For Notification timeout=${10} Reply By 200 ${notification_headers}= Get Request Headers -- GitLab