Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
FS-4192: Welsh translations for EOI (#206)
Browse files Browse the repository at this point in the history
* FS-4192: Welsh translations for EOI

* FS-4192: Add unit test for language difference
  • Loading branch information
tferns authored Mar 14, 2024
1 parent 32960f2 commit 053979b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
2 changes: 2 additions & 0 deletions app/notification/application/map_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Application(_NotificationContents):
reply_to_email_id: str
submission_date: str = None
caveats: str = None
language: str = None

@property
def format_submission_date(self):
Expand Down Expand Up @@ -74,6 +75,7 @@ def from_notification(cls, notification: Notification):
fund_id=application_data.get("fund_id"),
round_name=application_data.get("round_name"),
reference=application_data.get("reference"),
language=application_data.get("language"),
reply_to_email_id=Config.REPLY_TO_EMAILS_WITH_NOTIFY_ID[
notification.content.get(
NotifyConstants.MAGIC_LINK_CONTACT_HELP_EMAIL_FIELD
Expand Down
2 changes: 1 addition & 1 deletion app/notification/model/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def send_submitted_eoi(
email_address=contents.contact_info,
template_id=Config.EXPRESSION_OF_INTEREST_TEMPLATE_ID[
contents.fund_id
][template_name]["template_id"],
][template_name]["template_id"].get(contents.language, "en"),
email_reply_to_id=contents.reply_to_email_id,
personalisation={
"name of fund": contents.fund_name,
Expand Down
10 changes: 8 additions & 2 deletions config/envs/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ class DefaultConfig:
"54c11ec2-0b16-46bb-80d2-f210e47a8791": {
NotifyConstants.TEMPLATE_TYPE_EOI_PASS: {
"fund_name": "COF",
"template_id": "04db42f4-a74e-4ab3-b9e2-565592fd6f46",
"template_id": {
"en": "04db42f4-a74e-4ab3-b9e2-565592fd6f46",
"cy": "46915152-ee11-4bce-a0e1-ce1033078640",
},
},
NotifyConstants.TEMPLATE_TYPE_EOI_PASS_W_CAVEATS: {
"fund_name": "COF",
"template_id": "705684c7-6985-4d4c-9170-08a85f47b8e1",
"template_id": {
"en": "705684c7-6985-4d4c-9170-08a85f47b8e1",
"cy": "ead6bfc2-f3a1-468c-8d5a-87a32bf31311",
},
},
},
}
Expand Down
10 changes: 6 additions & 4 deletions examplar_data/application_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@


def notification_class_data_for_application(
date_submitted=True, deadline_date=True
date_submitted=True, deadline_date=True, language="en"
):
return Notification(
template_type="APPLICATION_RECORD_OF_SUBMISSION",
contact_info="sender@service.gov.uk",
contact_name="Test User",
content={
"application": {
"language": "en",
"language": language,
"reference": "NSTF",
"id": "7bc21539",
"status": "SUBMITTED",
Expand Down Expand Up @@ -188,14 +188,16 @@ def notification_class_data_for_application(
)


def notification_class_data_for_eoi(date_submitted=True, deadline_date=True):
def notification_class_data_for_eoi(
date_submitted=True, deadline_date=True, language="en"
):
return Notification(
template_type="APPLICATION_RECORD_OF_SUBMISSION",
contact_info="sender@service.gov.uk",
contact_name="Test User",
content={
"application": {
"language": "en",
"language": language,
"reference": "EOI",
"id": "7bc21539",
"status": "SUBMITTED",
Expand Down
23 changes: 19 additions & 4 deletions tests/test_application/test_application.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from unittest.mock import ANY

import pytest
from app.notification.application.map_contents import Application
Expand Down Expand Up @@ -141,22 +142,36 @@ def test_send_submitted_application(


@pytest.mark.parametrize(
"mock_notifications_api_client",
[3],
indirect=True,
"mock_notifications_api_client, language, template_id",
[
(3, "en", "705684c7-6985-4d4c-9170-08a85f47b8e1"),
(3, "cy", "ead6bfc2-f3a1-468c-8d5a-87a32bf31311"),
],
indirect=["mock_notifications_api_client"],
)
def test_send_submitted_eoi(
app_context,
mock_notifier_api_client,
mock_notifications_api_client,
language,
template_id,
):
_, code = Notifier.send_submitted_eoi(
notification=notification_class_data_for_eoi(
date_submitted=True, deadline_date=False
date_submitted=True,
deadline_date=False,
language=language,
),
template_name="Pass with caveats",
)

mock_notifications_api_client.send_email_notification.assert_called_with(
email_address=ANY,
template_id=template_id,
email_reply_to_id=ANY,
personalisation=ANY,
)

assert code == 200


Expand Down

0 comments on commit 053979b

Please sign in to comment.