Skip to content

Commit

Permalink
UTILS-169 Upgrade Mistune to v3 (#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
kalbfled authored Dec 18, 2024
1 parent 2d340c7 commit 1870e76
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fileignoreconfig:
- filename: lambda_functions/va_profile/va_profile_opt_in_out_lambda.py
checksum: a05165537ffbfac90000c5d04d8628251d771f6d1334c91c3aed28bf6c32368c
- filename: poetry.lock
checksum: 0d77076ee13746c0b551ea8bd40cf15a6f92277102b6d2020bf87a39394af49c
checksum: 099b2059d9ef8b472afbd7029680f16b4833c35feca2cf9a5acc2e6f7a8ffa9e
- filename: scripts/trigger_task.py
checksum: 0e9d244dbe285de23fc84bb643407963dacf7d25a3358373f01f6272fb217778
- filename: tests/README.md
Expand Down
4 changes: 2 additions & 2 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def process_job(
for row in RecipientCSV(
s3.get_job_from_s3(str(service.id), str(job_id)),
template_type=template.template_type,
placeholders=template.placeholders,
placeholders=template.placeholder_names,
).get_rows():
process_row(row, template, job, service, sender_id=sender_id)

Expand Down Expand Up @@ -578,7 +578,7 @@ def process_incomplete_job(job_id):
for row in RecipientCSV(
s3.get_job_from_s3(str(job.service_id), str(job.id)),
template_type=template.template_type,
placeholders=template.placeholders,
placeholders=template.placeholder_names,
).get_rows():
if row.index > resume_from_row:
process_row(row, template, job, job.service)
Expand Down
13 changes: 2 additions & 11 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
validate_email_address,
validate_phone_number,
)
from notifications_utils.template import (
LetterPrintTemplate,
PlainTextEmailTemplate,
SMSMessageTemplate,
)
from notifications_utils.template import PlainTextEmailTemplate, SMSMessageTemplate
from notifications_utils.timezones import convert_local_timezone_to_utc, convert_utc_to_local_timezone

from app import encryption
Expand Down Expand Up @@ -933,11 +929,6 @@ def _as_utils_template(self):
return PlainTextEmailTemplate({'content': self.content, 'subject': self.subject})
if self.template_type == SMS_TYPE:
return SMSMessageTemplate({'content': self.content})
if self.template_type == LETTER_TYPE:
return LetterPrintTemplate(
{'content': self.content, 'subject': self.subject},
contact_block=self.service.get_default_letter_contact(),
)

def serialize(self):
serialized = {
Expand All @@ -954,7 +945,7 @@ def serialize(self):
key: {
'required': True,
}
for key in self._as_utils_template().placeholders
for key in self._as_utils_template().placeholder_names
},
'postage': self.postage,
}
Expand Down
16 changes: 8 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions tests/app/dao/test_fact_notification_status_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,9 @@ def test_fetch_notification_status_by_template_for_service_for_today_and_7_previ
sms_template = sample_template(service=service, template_type=SMS_TYPE, name=f'a {uuid4()}')
sms_template_2 = sample_template(service=service, template_type=SMS_TYPE, name=f'b {uuid4()}')
email_template = sample_template(service=service, template_type=EMAIL_TYPE)
letter_template = sample_template(service=service, template_type=LETTER_TYPE)

job_sms = sample_job(sms_template)
job_email = sample_job(email_template)
job_letter = sample_job(letter_template)

# create unused email template
sample_template(service=service, template_type=EMAIL_TYPE)
Expand All @@ -333,7 +331,6 @@ def test_fetch_notification_status_by_template_for_service_for_today_and_7_previ
sample_ft_notification_status(date(1993, 10, 24), job_sms, count=8)
sample_ft_notification_status(date(1993, 10, 29), job_sms, notification_status='created')
sample_ft_notification_status(date(1993, 10, 29), job_email, count=3)
sample_ft_notification_status(date(1993, 10, 26), job_letter, count=5)

sample_notification(template=sms_template, created_at=datetime(1993, 10, 31, 11, 0, 0))
sample_notification(template=sms_template, created_at=datetime(1993, 10, 31, 12, 0, 0), status='delivered')
Expand All @@ -347,7 +344,6 @@ def test_fetch_notification_status_by_template_for_service_for_today_and_7_previ

assert [
(email_template.name, False, mock.ANY, EMAIL_TYPE, 'delivered', 4),
(letter_template.name, False, mock.ANY, LETTER_TYPE, 'delivered', 5),
(sms_template.name, False, mock.ANY, SMS_TYPE, 'created', 2),
(sms_template.name, False, mock.ANY, SMS_TYPE, 'delivered', 11),
(sms_template_2.name, False, mock.ANY, SMS_TYPE, 'delivered', 1),
Expand Down
4 changes: 2 additions & 2 deletions tests/app/delivery/test_send_to_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test_should_send_personalised_template_to_correct_email_provider_and_persist
template = sample_template(
template_type=EMAIL_TYPE,
subject='((name)) <em>some HTML</em>',
content='Hello ((name))\nThis is an email from GOV.UK with <em>some HTML</em>',
content='Hello ((name))\nThis is an email from VA with <em>some HTML</em>',
)
db_notification = sample_notification(
template=template,
Expand All @@ -188,7 +188,7 @@ def test_should_send_personalised_template_to_correct_email_provider_and_persist
source=mock_source_email_address[0],
to_addresses='jo.smith@example.com',
subject='Jo <em>some HTML</em>',
body='Hello Jo\nThis is an email from GOV.\u200bUK with <em>some HTML</em>\n',
body='Hello Jo\nThis is an email from VA with <em>some HTML</em>\n\n',
html_body=ANY,
reply_to_address=None,
attachments=[],
Expand Down

0 comments on commit 1870e76

Please sign in to comment.