From a05da0ae11f3c14290a046f26c93fd29aa67dc35 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Tue, 17 Dec 2024 13:14:19 +0000 Subject: [PATCH] Fix tests --- .../dataset_subscriptions/actions/twilio_notifications.py | 6 +++--- .../tests/actions/test_twilio_notifications.py | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ckanext/dataset_subscriptions/actions/twilio_notifications.py b/ckanext/dataset_subscriptions/actions/twilio_notifications.py index edbf71e..4ac6eea 100644 --- a/ckanext/dataset_subscriptions/actions/twilio_notifications.py +++ b/ckanext/dataset_subscriptions/actions/twilio_notifications.py @@ -34,16 +34,16 @@ def send_twilio_notifications(context, data_dict): {'all_fields': True, 'include_plugin_extras': True} ) for user in users: - if _twilio_notifications_enabled(user): + if _twilio_notifications_enabled(user, data_dict): recent_activities = _get_recent_activity_list(user, context) if recent_activities: - if _sms_notifications_enabled(user): + if _sms_notifications_enabled(user, data_dict): message_sids.append(_send_message( _create_sms_message(recent_activities), SMS_SENDER_NR, user['phonenumber'] )) - if _whatsapp_notifications_enabled(user): + if _whatsapp_notifications_enabled(user, data_dict): message_sids.append(_send_message( _create_message_header(recent_activities), f"whatsapp:{WHATSAPP_SENDER_NR}", diff --git a/ckanext/dataset_subscriptions/tests/actions/test_twilio_notifications.py b/ckanext/dataset_subscriptions/tests/actions/test_twilio_notifications.py index e058d77..7f35120 100644 --- a/ckanext/dataset_subscriptions/tests/actions/test_twilio_notifications.py +++ b/ckanext/dataset_subscriptions/tests/actions/test_twilio_notifications.py @@ -47,7 +47,7 @@ def create_user_with_resources(with_activity, @pytest.mark.parametrize("notifications_enabled", [(False), (True)]) def test_sms_notifications_disabled_enabled(notifications_enabled): user = create_user_with_resources(True, notifications_enabled, False) - notifications = twilio_notifications._sms_notifications_enabled(user) + notifications = twilio_notifications._sms_notifications_enabled(user, {}) assert notifications == notifications_enabled @@ -59,8 +59,7 @@ def test_if_sms_notifications_are_generated(create_message_mock, sysadmin_contex create_user_with_resources(True, True, False) expected_sid = 'SM87105da94bff44b999e4e6eb90d8eb6a' create_message_mock.return_value.sid = expected_sid - sid = helpers.call_action("send_sms_notifications") - print(sid) + sid = helpers.call_action("send_twilio_notifications") assert create_message_mock.called is True assert sid[0] == expected_sid @@ -73,8 +72,7 @@ def test_if_whatsapp_notifications_are_generated(create_message_mock, sysadmin_c create_user_with_resources(True, False, True) expected_sid = 'SM87105da94bff44b999e4e6eb90d8eb6a' create_message_mock.return_value.sid = expected_sid - sid = helpers.call_action("send_sms_notifications") - print(sid) + sid = helpers.call_action("send_twilio_notifications") assert create_message_mock.called is True assert sid[0] == expected_sid call_args = dict(create_message_mock.call_args.kwargs.items())