mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Updated notifications_utils version and associated code. Added email subject formatting for placeholders.
This commit is contained in:
@@ -45,14 +45,22 @@ def service_json(id_, name, users, message_limit=1000, active=False, restricted=
|
||||
}
|
||||
|
||||
|
||||
def template_json(service_id, id_, name="sample template", type_="sms", content="template content"):
|
||||
return {
|
||||
def template_json(service_id,
|
||||
id_,
|
||||
name="sample template",
|
||||
type_="sms",
|
||||
content="template content",
|
||||
subject=None):
|
||||
template = {
|
||||
'id': id_,
|
||||
'name': name,
|
||||
'template_type': type_,
|
||||
'content': content,
|
||||
'service': service_id
|
||||
}
|
||||
if subject is not None:
|
||||
template['subject'] = subject
|
||||
return template
|
||||
|
||||
|
||||
def api_key_json(id_, name, expiry_date=None):
|
||||
|
||||
@@ -2,7 +2,7 @@ import json
|
||||
from datetime import datetime
|
||||
|
||||
from flask import url_for
|
||||
from utils.url_safe_token import generate_token
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
|
||||
|
||||
def test_should_render_new_password_template(app_,
|
||||
|
||||
@@ -76,7 +76,7 @@ def test_verify_email_redirects_to_verify_if_token_valid(app_,
|
||||
mock_check_verify_code):
|
||||
import json
|
||||
token_data = {"user_id": api_user_pending.id, "secret_code": 12345}
|
||||
mocker.patch('utils.url_safe_token.check_token', return_value=json.dumps(token_data))
|
||||
mocker.patch('app.main.views.verify.check_token', return_value=json.dumps(token_data))
|
||||
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
@@ -94,7 +94,7 @@ def test_verify_email_redirects_to_email_sent_if_token_expired(app_,
|
||||
api_user_pending,
|
||||
mock_check_verify_code):
|
||||
from itsdangerous import SignatureExpired
|
||||
mocker.patch('utils.url_safe_token.check_token', side_effect=SignatureExpired('expired'))
|
||||
mocker.patch('app.main.views.verify.check_token', side_effect=SignatureExpired('expired'))
|
||||
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
@@ -114,7 +114,7 @@ def test_verify_email_redirects_to_email_sent_if_token_used(app_,
|
||||
mock_send_verify_code,
|
||||
mock_check_verify_code_code_expired):
|
||||
from itsdangerous import SignatureExpired
|
||||
mocker.patch('utils.url_safe_token.check_token', side_effect=SignatureExpired('expired'))
|
||||
mocker.patch('app.main.views.verify.check_token', side_effect=SignatureExpired('expired'))
|
||||
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
@@ -135,7 +135,7 @@ def test_verify_email_redirects_to_sign_in_if_user_active(app_,
|
||||
mock_check_verify_code):
|
||||
import json
|
||||
token_data = {"user_id": api_user_active.id, "secret_code": 12345}
|
||||
mocker.patch('utils.url_safe_token.check_token', return_value=json.dumps(token_data))
|
||||
mocker.patch('app.main.views.verify.check_token', return_value=json.dumps(token_data))
|
||||
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
|
||||
@@ -180,7 +180,11 @@ def mock_get_service_template(mocker):
|
||||
def mock_get_service_email_template(mocker):
|
||||
def _create(service_id, template_id):
|
||||
template = template_json(
|
||||
service_id, template_id, "Two week reminder", "email", "Your vehicle tax is about to expire")
|
||||
service_id,
|
||||
template_id,
|
||||
"Two week reminder",
|
||||
"email",
|
||||
"Your vehicle tax is about to expire", "Subject")
|
||||
return {'data': template}
|
||||
|
||||
return mocker.patch(
|
||||
|
||||
Reference in New Issue
Block a user