From d29a47d7cddf6e456945f4a8a612ac4e090f8bdb Mon Sep 17 00:00:00 2001 From: Carina Antunes <carina.oliveira.antunes@cern.ch> Date: Fri, 18 Mar 2022 17:22:17 +0100 Subject: [PATCH] fix parameter call and add tests --- notifications_routing/router.py | 4 ++-- tests/unit/test_router.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/notifications_routing/router.py b/notifications_routing/router.py index 9395c42..beae0fb 100644 --- a/notifications_routing/router.py +++ b/notifications_routing/router.py @@ -127,10 +127,10 @@ class Router(megabus.Listener): def get_target_users(self, notification_id, channel_id): """Join users from our data source and the grappa system to return a unique users list.""" - target_users = self.data_source.get_target_users(channel_id) + target_users = self.data_source.get_target_users(notification_id) logging.debug("channel %s targeted users %s", channel_id, target_users) - target_groups = self.data_source.get_target_groups(channel_id) + target_groups = self.data_source.get_target_groups(notification_id) logging.debug("channel %s targeted groups %s", channel_id, target_groups) if not (target_groups or target_users): diff --git a/tests/unit/test_router.py b/tests/unit/test_router.py index 2cec64f..240cf8d 100644 --- a/tests/unit/test_router.py +++ b/tests/unit/test_router.py @@ -154,10 +154,12 @@ def test_process_users_target_users( system_user_3, ] - assert router_mock.get_target_users(ANY, ANY) == [system_user_2, no_system_user_1, system_user_3] - router_mock.data_source.get_target_users.assert_called_once() - router_mock.data_source.get_target_groups.assert_called_once() - router_mock.data_source.get_target_groups.get_channel_unsubscribed_users() + notif_id = "a" + channel_id = "b" + assert router_mock.get_target_users(notif_id, channel_id) == [system_user_2, no_system_user_1, system_user_3] + router_mock.data_source.get_target_users.assert_called_once_with(notif_id) + router_mock.data_source.get_target_groups.assert_called_once_with(notif_id) + router_mock.data_source.get_channel_unsubscribed_users.assert_called_once_with(channel_id) assert router_mock.data_source.get_group_users.call_count == 2 assert router_mock.data_source.get_system_user.call_count == 2 -- GitLab