Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansberry committed Dec 17, 2024
1 parent aef24ee commit a05da0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ckanext/dataset_subscriptions/actions/twilio_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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

Expand All @@ -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())
Expand Down

0 comments on commit a05da0a

Please sign in to comment.