Merge pull request #673 from alphagov/provide-simulated-numbers-live-keys

Add capability for simulated numbers and email addresses
This commit is contained in:
imdadahad
2016-09-14 15:23:12 +01:00
committed by GitHub
3 changed files with 82 additions and 13 deletions

View File

@@ -217,7 +217,6 @@ def send_notification(notification_type):
template_id=notification['template'],
service_id=service_id
)
errors = unarchived_template_schema.validate({'archived': template.archived})
if errors:
raise InvalidRequest(errors, status_code=400)
@@ -270,15 +269,17 @@ def send_notification(notification_type):
notification_id = create_uuid()
notification.update({"template_version": template.version})
persist_notification(
service,
notification_id,
notification,
datetime.utcnow().strftime(DATETIME_FORMAT),
notification_type,
str(api_user.id),
api_user.key_type
)
if not _simulated_recipient(notification['to'], notification_type):
persist_notification(
service,
notification_id,
notification,
datetime.utcnow().strftime(DATETIME_FORMAT),
notification_type,
str(api_user.id),
api_user.key_type
)
return jsonify(
data=get_notification_return_data(
@@ -311,6 +312,12 @@ def get_notification_statistics_for_day():
return jsonify(data=data), 200
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'])
def persist_notification(
service,
notification_id,