- 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:
Rebecca Law
2017-01-17 12:08:24 +00:00
parent 31de10ae6f
commit a8cdabcecd
11 changed files with 193 additions and 104 deletions

View File

@@ -41,7 +41,8 @@ def persist_notification(template_id,
job_id=None,
job_row_number=None,
reference=None,
notification_id=None):
notification_id=None,
simulated=False):
notification = Notification(
id=notification_id,
template_id=template_id,
@@ -58,8 +59,9 @@ def persist_notification(template_id,
job_row_number=job_row_number,
client_reference=reference
)
dao_create_notification(notification)
redis_store.incr(redis.daily_limit_cache_key(service.id))
if not simulated:
dao_create_notification(notification)
redis_store.incr(redis.daily_limit_cache_key(service.id))
return notification
@@ -87,3 +89,9 @@ def send_notification_to_queue(notification, research_mode, queue=None):
current_app.logger.info(
"{} {} created at {}".format(notification.notification_type, notification.id, notification.created_at)
)
def simulated_recipient(to_address, notification_type):
return (to_address in current_app.config['SIMULATED_SMS_NUMBERS']
if notification_type == SMS_TYPE
else to_address in current_app.config['SIMULATED_EMAIL_ADDRESSES'])