fix tests

This commit is contained in:
Kenneth Kehl
2024-01-22 10:55:09 -08:00
parent ed3a356ad1
commit 6dc9828663
19 changed files with 282 additions and 99 deletions

View File

@@ -120,22 +120,23 @@ def update_user_attribute(user_id):
else:
return jsonify(data=user_to_update.serialize()), 200
service = Service.query.get(current_app.config["NOTIFY_SERVICE_ID"])
personalisation = {
"name": user_to_update.name,
"servicemanagername": updated_by.name,
"email address": user_to_update.email_address,
}
saved_notification = persist_notification(
template_id=template.id,
template_version=template.version,
recipient=recipient,
service=service,
personalisation={
"name": user_to_update.name,
"servicemanagername": updated_by.name,
"email address": user_to_update.email_address,
},
personalisation={},
notification_type=template.template_type,
api_key_id=None,
key_type=KEY_TYPE_NORMAL,
reply_to_text=reply_to,
)
saved_notification.personalisation = personalisation
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
@@ -371,24 +372,25 @@ def send_user_confirm_new_email(user_id):
current_app.config["CHANGE_EMAIL_CONFIRMATION_TEMPLATE_ID"]
)
service = Service.query.get(current_app.config["NOTIFY_SERVICE_ID"])
personalisation = {
"name": user_to_send_to.name,
"url": _create_confirmation_url(
user=user_to_send_to, email_address=email["email"]
),
"feedback_url": current_app.config["ADMIN_BASE_URL"] + "/support",
}
saved_notification = persist_notification(
template_id=template.id,
template_version=template.version,
recipient=email["email"],
service=service,
personalisation={
"name": user_to_send_to.name,
"url": _create_confirmation_url(
user=user_to_send_to, email_address=email["email"]
),
"feedback_url": current_app.config["ADMIN_BASE_URL"] + "/support",
},
personalisation={},
notification_type=template.template_type,
api_key_id=None,
key_type=KEY_TYPE_NORMAL,
reply_to_text=service.get_default_reply_to_email_address(),
)
saved_notification.personalisation = personalisation
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
return jsonify({}), 204
@@ -409,24 +411,25 @@ def send_new_user_email_verification(user_id):
current_app.logger.info("template.id is {}".format(template.id))
current_app.logger.info("service.id is {}".format(service.id))
personalisation = {
"name": user_to_send_to.name,
"url": _create_verification_url(
user_to_send_to,
base_url=request_json.get("admin_base_url"),
),
}
saved_notification = persist_notification(
template_id=template.id,
template_version=template.version,
recipient=user_to_send_to.email_address,
service=service,
personalisation={
"name": user_to_send_to.name,
"url": _create_verification_url(
user_to_send_to,
base_url=request_json.get("admin_base_url"),
),
},
personalisation={},
notification_type=template.template_type,
api_key_id=None,
key_type=KEY_TYPE_NORMAL,
reply_to_text=service.get_default_reply_to_email_address(),
)
saved_notification.personalisation = personalisation
redis_store.set(
f"email-address-{saved_notification.id}",
@@ -456,23 +459,24 @@ def send_already_registered_email(user_id):
current_app.logger.info("template.id is {}".format(template.id))
current_app.logger.info("service.id is {}".format(service.id))
personalisation = {
"signin_url": current_app.config["ADMIN_BASE_URL"] + "/sign-in",
"forgot_password_url": current_app.config["ADMIN_BASE_URL"]
+ "/forgot-password",
"feedback_url": current_app.config["ADMIN_BASE_URL"] + "/support",
}
saved_notification = persist_notification(
template_id=template.id,
template_version=template.version,
recipient=to["email"],
service=service,
personalisation={
"signin_url": current_app.config["ADMIN_BASE_URL"] + "/sign-in",
"forgot_password_url": current_app.config["ADMIN_BASE_URL"]
+ "/forgot-password",
"feedback_url": current_app.config["ADMIN_BASE_URL"] + "/support",
},
personalisation={},
notification_type=template.template_type,
api_key_id=None,
key_type=KEY_TYPE_NORMAL,
reply_to_text=service.get_default_reply_to_email_address(),
)
saved_notification.personalisation = personalisation
current_app.logger.info("Sending notification to queue")
@@ -572,24 +576,26 @@ def send_user_reset_password():
user_to_send_to = get_user_by_email(email["email"])
template = dao_get_template_by_id(current_app.config["PASSWORD_RESET_TEMPLATE_ID"])
service = Service.query.get(current_app.config["NOTIFY_SERVICE_ID"])
personalisation = {
"user_name": user_to_send_to.name,
"url": _create_reset_password_url(
user_to_send_to.email_address,
base_url=request_json.get("admin_base_url"),
next_redirect=request_json.get("next"),
),
}
saved_notification = persist_notification(
template_id=template.id,
template_version=template.version,
recipient=email["email"],
service=service,
personalisation={
"user_name": user_to_send_to.name,
"url": _create_reset_password_url(
user_to_send_to.email_address,
base_url=request_json.get("admin_base_url"),
next_redirect=request_json.get("next"),
),
},
personalisation=None,
notification_type=template.template_type,
api_key_id=None,
key_type=KEY_TYPE_NORMAL,
reply_to_text=service.get_default_reply_to_email_address(),
)
saved_notification.personalisation = personalisation
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)