diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_01.robot index 8240fc842b0d1231295225e54659673015ad7636..aea73282cda1f18c4004b5791339ca3bc8dd2670 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 dacc53db962d604ce59a2958faae88c8b98e5826..1ae54eb5b76d48c55212a78db791342fb35c8360 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 @@ -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 11aacaeaca0ed96958572e4455d56c3e86288990..55a3a61c1269384aeeb011943ac76ff160eabe3a 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 - ${notification}= Wait for notification ${5} + Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + + ${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 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 8a28883c1e5fbe25b272d273079068a254a5ac6f..c3d91068ad2be82764a2500133f3a3f8f5ccb769 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 @@ -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 ddd662ed7385670ebc42d499ab4df034466ddd65..53bb74844337febdd21e144ee43a0f3b1ac0a1c2 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 @@ -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 bed35306312373a12adcfd10f75720cdb6282bd1..7f9afb76d4b0c5a590f8cfd937a360dd27b63390 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,14 +21,14 @@ ${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} ... ${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 0f88bd876e8cd3c5f844ac2753f2d6658ae9db71..5893ecaa7bfebe3014d66d97013e1a035c742620 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_07.robot @@ -33,12 +33,11 @@ ${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} - ${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 @@ -49,12 +48,11 @@ ${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} - ${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 @@ -66,12 +64,11 @@ ${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} - ${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_08.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_08.robot index ce1233dabd8fe2eb91f07c9b16702f6aa3419b59..397f05dde80124aeb911f7f41fc4fb532abb257c 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_09.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_09.robot index 0c6c624bc04c907113844b8f2d17010bee633d2f..4478fa41ed2854b0c6da632789a4b327b21ec506 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/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_10.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_10.robot index 8de74ab1f6916cdf5299d2d0e23fde2d6fbc799d..785bc200f83ddba8bb79515184dcfe86da51a8f8 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 367cc143b8823925e4a4f2956a1a5e81199fd406..7dd5003d1dbd88b2b2c3a41a0a2553b9f061ef78 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 8ab02f20b8aac17073cd21999c16178ebeb746f3..6007a7ab9d39869800d244af0b58498b648b7fca 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 210470b9350e60aa721302c91f419a934e03b945..05fe6d3feb3398fe8b9274216f726bf67834c42e 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 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 a6bd1088b592fe44070de914d0baab7059fe5691..7e907cdbbd17f8d197a9e79da2f0f3a637a90949 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 2cce39704ac439f29b68e883ea9b299adafcabbc..7166057132955a0458f00094ccd8c900b08aebd3 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 6b82b53953c5c8740f67e5882e112fe9d6423161..ae9fc0891a275e7b1a4f7885f0fb1c1fd67e33ec 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/libraries/logUtils.py b/libraries/logUtils.py index 9254bc599d6f592248d523684521aa184b0095c9..c796a1896a2009e61da985ac7b1a7eae81bef1fa 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 ac978eba7c3750acf5fdfda54341033f953ee81f..38f546ad81e7ff7e30c5d638247b9494dbfd128b 100644 --- a/resources/NotificationUtils.resource +++ b/resources/NotificationUtils.resource @@ -31,8 +31,11 @@ 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} + Output Notification ${notification} ${notification_headers} Wait for notification + RETURN ${notification} ${headers} Wait for notification and validate it [Arguments] @@ -49,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}