Fixed test_rest file

This commit is contained in:
alexjanousekGSA
2025-05-14 13:41:23 -04:00
parent 2824056a7d
commit 68aa63945a
3 changed files with 20 additions and 18 deletions

View File

@@ -51,7 +51,7 @@ def get_notification_by_id(notification_id):
notification.to = recipient
notification.normalised_to = recipient
serialized = PublicNotificationSchema().dump(notification)
serialized = notification_with_personalisation_schema.dump(notification)
return jsonify(data={"notification": serialized}), 200

View File

@@ -639,27 +639,29 @@ class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema):
in_data._merged_personalisation = in_data.personalisation
return in_data
@post_dump(pass_original=True)
def handle_template_merge(self, in_data, original_obj, **kwargs):
personalisation = getattr(original_obj, "_merged_personalisation", None)
@post_dump(pass_original=True)
def handle_template_merge(self, in_data, original_obj, **kwargs):
personalisation = getattr(original_obj, "_merged_personalisation", None)
in_data["template"] = in_data.pop("template_history")
template = get_template_instance(in_data["template"], personalisation)
in_data["template"] = in_data.pop("template_history")
template = get_template_instance(in_data["template"], personalisation)
in_data["body"] = template.content_with_placeholders_filled_in
in_data["body"] = template.content_with_placeholders_filled_in
if in_data["template"]["template_type"] != TemplateType.SMS:
in_data["subject"] = template.subject
in_data["content_char_count"] = None
else:
in_data["content_char_count"] = template.content_count
in_data["template"].pop("content", None)
in_data["template"].pop("subject", None)
in_data.pop("personalisation", None)
return in_data
if in_data["template"]["template_type"] != TemplateType.SMS:
in_data["subject"] = template.subject
in_data["content_char_count"] = None
else:
in_data["content_char_count"] = template.content_count
in_data["template"].pop("content", None)
in_data["template"].pop("subject", None)
in_data.pop("personalisation", None)
return in_data
class InvitedUserSchema(BaseSchema):

View File

@@ -558,8 +558,8 @@ def test_get_notification_by_id_returns_merged_template_content(
def test_get_notification_by_id_returns_merged_template_content_for_email(
client, sample_email_template_with_placeholders, mocker
):
mock_s3 = mocker.patch("app.notifications.rest.get_personalisation_from_s3")
mock_s3.return_value = {"name": "foo"}
# mock_s3 = mocker.patch("app.notifications.rest.get_personalisation_from_s3")
# mock_s3.return_value = {"name": "foo"}
sample_notification = create_notification(
sample_email_template_with_placeholders, personalisation={"name": "world"}
)