From 4895e4d42cc396ea0ffc99572e7e66d7e59a0bc1 Mon Sep 17 00:00:00 2001 From: Caetan Tojeiro Carpente <caetan.tojeiro.carpente@cern.ch> Date: Mon, 10 Jul 2023 20:23:49 +0200 Subject: [PATCH] [#84] Short URL integration --- notifications_routing/router.py | 1 + notifications_routing/utils.py | 2 ++ tests/unit/conftest.py | 4 ++++ tests/unit/test_postgres_data_source.py | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/notifications_routing/router.py b/notifications_routing/router.py index 3e1f5b9..ca6d711 100644 --- a/notifications_routing/router.py +++ b/notifications_routing/router.py @@ -65,6 +65,7 @@ class Router(megabus.Listener): str(OutputMessageKeys.CHANNEL_ID): channel[str(InputMessageKeys.ID)], str(OutputMessageKeys.CHANNEL_NAME): channel[str(InputMessageKeys.NAME)], str(OutputMessageKeys.CHANNEL_SLUG): channel[str(InputMessageKeys.SLUG)], + str(OutputMessageKeys.CHANNEL_SHORT_URL): channel[str(InputMessageKeys.SHORT_URL)], str(OutputMessageKeys.PRIORITY): message_json[str(InputMessageKeys.PRIORITY)], str(OutputMessageKeys.CREATED_TIMESTAMP): convert_timestamp_to_local_timezone( message_json[str(InputMessageKeys.SENT_AT)] diff --git a/notifications_routing/utils.py b/notifications_routing/utils.py index 1c10bde..980cb49 100644 --- a/notifications_routing/utils.py +++ b/notifications_routing/utils.py @@ -22,6 +22,7 @@ class InputMessageKeys(StrEnum): NAME = "name" CATEGORY = "category" SLUG = "slug" + SHORT_URL = "shortUrl" PRIORITY = "priority" SENT_AT = "sentAt" BODY = "body" @@ -39,6 +40,7 @@ class OutputMessageKeys(StrEnum): CHANNEL_NAME = "channel_name" CHANNEL_CATEGORY = "category_name" CHANNEL_SLUG = "channel_slug" + CHANNEL_SHORT_URL = "channel_short_url" PRIORITY = "priority" CREATED_TIMESTAMP = "created_timestamp" MESSAGE_BODY = "message_body" diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index c1d6cd4..72ec7d2 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -127,6 +127,7 @@ def message(): "channel_id": "c3ccc15b-298f-4dc7-877f-2c8970331caf", "channel_name": "Test channel", "channel_slug": "test-channel", + "channel_short_url": "https://cern.ch/thisisanexample", "priority": "NORMAL", "created_timestamp": "2021-02-26T13:59:40.754Z", "message_body": "test", @@ -146,6 +147,7 @@ def message_private(): "channel_id": "c3ccc15b-298f-4dc7-877f-2c8970331caf", "channel_name": "Test channel", "channel_slug": "test-channel", + "channel_short_url": "https://cern.ch/thisisanexample", "priority": "NORMAL", "created_timestamp": "2021-02-26T13:59:40.754Z", "message_body": "test", @@ -165,6 +167,7 @@ def message_intersection(): "channel_id": "c3ccc15b-298f-4dc7-877f-2c8970331caf", "channel_name": "Test channel", "channel_slug": "test-channel", + "channel_short_url": "https://cern.ch/thisisanexample", "priority": "NORMAL", "created_timestamp": "2021-02-26T13:59:40.754Z", "message_body": "test", @@ -184,6 +187,7 @@ def message_critical(): "channel_id": "c3ccc15b-298f-4dc7-877f-2c8970331caf", "channel_name": "Test channel", "channel_slug": "test-channel", + "channel_short_url": "https://cern.ch/thisisanexample", "priority": "CRITICAL", "created_timestamp": "2021-02-26T13:59:40.754Z", "message_body": "test", diff --git a/tests/unit/test_postgres_data_source.py b/tests/unit/test_postgres_data_source.py index 2e3f6ff..b098189 100644 --- a/tests/unit/test_postgres_data_source.py +++ b/tests/unit/test_postgres_data_source.py @@ -35,7 +35,7 @@ def channel(): return Channel( id="c3ccc15b-298f-4dc7-877f-2c8970331caf", slug="test-channel", - name="Test Chanel", + name="Test Channel", groups=[ Group( id="186d8dfc-2774-43a8-91b5-a887fcb6ba4a", -- GitLab