mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 16:23:44 -04:00
Fixed test_rest file
This commit is contained in:
@@ -51,7 +51,7 @@ def get_notification_by_id(notification_id):
|
|||||||
notification.to = recipient
|
notification.to = recipient
|
||||||
notification.normalised_to = recipient
|
notification.normalised_to = recipient
|
||||||
|
|
||||||
serialized = PublicNotificationSchema().dump(notification)
|
serialized = notification_with_personalisation_schema.dump(notification)
|
||||||
return jsonify(data={"notification": serialized}), 200
|
return jsonify(data={"notification": serialized}), 200
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -639,27 +639,29 @@ class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema):
|
|||||||
in_data._merged_personalisation = in_data.personalisation
|
in_data._merged_personalisation = in_data.personalisation
|
||||||
return in_data
|
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)
|
in_data["template"] = in_data.pop("template_history")
|
||||||
def handle_template_merge(self, in_data, original_obj, **kwargs):
|
template = get_template_instance(in_data["template"], personalisation)
|
||||||
personalisation = getattr(original_obj, "_merged_personalisation", None)
|
|
||||||
|
|
||||||
in_data["template"] = in_data.pop("template_history")
|
in_data["body"] = template.content_with_placeholders_filled_in
|
||||||
template = get_template_instance(in_data["template"], personalisation)
|
|
||||||
|
|
||||||
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):
|
class InvitedUserSchema(BaseSchema):
|
||||||
|
|||||||
@@ -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(
|
def test_get_notification_by_id_returns_merged_template_content_for_email(
|
||||||
client, sample_email_template_with_placeholders, mocker
|
client, sample_email_template_with_placeholders, mocker
|
||||||
):
|
):
|
||||||
mock_s3 = mocker.patch("app.notifications.rest.get_personalisation_from_s3")
|
# mock_s3 = mocker.patch("app.notifications.rest.get_personalisation_from_s3")
|
||||||
mock_s3.return_value = {"name": "foo"}
|
# mock_s3.return_value = {"name": "foo"}
|
||||||
sample_notification = create_notification(
|
sample_notification = create_notification(
|
||||||
sample_email_template_with_placeholders, personalisation={"name": "world"}
|
sample_email_template_with_placeholders, personalisation={"name": "world"}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user