Skip to content

Commit

Permalink
[#2183] Fixed regression with optional status
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart van der Schoor authored and alextreme committed Mar 10, 2024
1 parent 9ab0329 commit 7e47793
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/open_inwoner/openzaak/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,14 @@ def send_case_update_email(
context = {
"identification": case.identification,
"type_description": case.zaaktype.omschrijving,
"status_description": translate_single_status(status.statustype.omschrijving),
"start_date": case.startdatum,
"end_date": date.today() + timedelta(days=config.action_required_deadline_days),
"case_link": case_detail_url,
}
if status:
context["status_description"] = (
translate_single_status(status.statustype.omschrijving),
)
if extra_context:
context.update(extra_context)
template.send_email([user.email], context)
Expand Down
24 changes: 24 additions & 0 deletions src/open_inwoner/openzaak/tests/test_notification_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ def test_send_case_update_email(self):
self.assertIn(case_url, body_html)
self.assertIn(config.name, body_html)

def test_send_case_update_email__no_status(self):
config = SiteConfiguration.get_solo()
data = MockAPIData()

user = data.user_initiator

case = factory(Zaak, data.zaak)
case.zaaktype = factory(ZaakType, data.zaak_type)

case_url = reverse("cases:case_detail", kwargs={"object_id": str(case.uuid)})

send_case_update_email(user, case, "case_document_notification")

self.assertEqual(len(mail.outbox), 1)
email = mail.outbox[0]
self.assertEqual(email.to, [user.email])
self.assertIn(config.name, email.subject)

body_html = email.alternatives[0][0]
self.assertIn(case.identificatie, body_html)
self.assertIn(case.zaaktype.omschrijving, body_html)
self.assertIn(case_url, body_html)
self.assertIn(config.name, body_html)

# TODO we're missing a similar test for get_nnp_initiator_nnp_id_from_roles()
def test_get_np_initiator_bsns_from_roles(self):
# roles we're interested in
Expand Down

0 comments on commit 7e47793

Please sign in to comment.