mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 00:11:16 -05:00
- Refactor v2 post_notification to use a single method for sms and email.
- Added the `simulate` notification logic to version 2. We have 3 email addresses and phone numbers that are used to simulate a successful post to /notifications. This was missed out of the version 2 endpoint. - Added a test to template_dao to check for the default value of normal for new templates - in v2 get_notifications, casted the path param to a uuid, if not uuid abort(404)
This commit is contained in:
@@ -10,7 +10,9 @@ from collections import namedtuple
|
||||
from app.models import Template, Notification, NotificationHistory
|
||||
from app.notifications import SendNotificationToQueueError
|
||||
from app.notifications.process_notifications import (create_content_for_notification,
|
||||
persist_notification, send_notification_to_queue)
|
||||
persist_notification,
|
||||
send_notification_to_queue,
|
||||
simulated_recipient)
|
||||
from app.v2.errors import BadRequestError
|
||||
|
||||
|
||||
@@ -193,3 +195,24 @@ def test_send_notification_to_queue_throws_exception_deletes_notification(sample
|
||||
|
||||
assert Notification.query.count() == 0
|
||||
assert NotificationHistory.query.count() == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize("to_address, notification_type, expected",
|
||||
[("+447700900000", "sms", True),
|
||||
("+447700900111", "sms", True),
|
||||
("+447700900222", "sms", True),
|
||||
("simulate-delivered@notifications.service.gov.uk", "email", True),
|
||||
("simulate-delivered-2@notifications.service.gov.uk", "email", True),
|
||||
("simulate-delivered-3@notifications.service.gov.uk", "email", True),
|
||||
("07515896969", "sms", False),
|
||||
("valid_email@test.com", "email", False)])
|
||||
def test_simulated_recipient(notify_api, to_address, notification_type, expected):
|
||||
# The values where the expected = 'research-mode' are listed in the config['SIMULATED_EMAIL_ADDRESSES']
|
||||
# and config['SIMULATED_SMS_NUMBERS']. These values should result in using the research mode queue.
|
||||
# SIMULATED_EMAIL_ADDRESSES = ('simulate-delivered@notifications.service.gov.uk',
|
||||
# 'simulate-delivered-2@notifications.service.gov.uk',
|
||||
# 'simulate-delivered-2@notifications.service.gov.uk')
|
||||
# SIMULATED_SMS_NUMBERS = ('+447700900000', '+447700900111', '+447700900222')
|
||||
|
||||
actual = simulated_recipient(to_address, notification_type)
|
||||
assert actual == expected
|
||||
|
||||
Reference in New Issue
Block a user