Skip to content

Commit

Permalink
Merge pull request #882 from maykinmedia/issue/1904-notification-dupl…
Browse files Browse the repository at this point in the history
…icate-statustypeconfig

🐛 [#1904] Fix status notification for duplicate configs
  • Loading branch information
alextreme authored Dec 11, 2023
2 parents 59dc8af + 2ff7285 commit c243c0a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/open_inwoner/openzaak/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ def _handle_status_notification(notification: Notification, case: Zaak, inform_u
status.statustype = status_type

# check the ZaakTypeConfig
ztc = get_zaak_type_config(case.zaaktype)
if oz_config.skip_notification_statustype_informeren:
ztc = get_zaak_type_config(case.zaaktype)
if not ztc:
log_system_action(
f"ignored {r} notification: 'skip_notification_statustype_informeren' is True but cannot retrieve case_type configuration '{case.zaaktype.identificatie}' for case {case.url}",
Expand All @@ -321,7 +321,7 @@ def _handle_status_notification(notification: Notification, case: Zaak, inform_u

try:
statustype_config = ZaakTypeStatusTypeConfig.objects.get(
statustype_url=statustype_url
zaaktype_config=ztc, statustype_url=statustype_url
)
except ZaakTypeStatusTypeConfig.DoesNotExist:
pass
Expand Down
33 changes: 32 additions & 1 deletion src/open_inwoner/openzaak/tests/test_notification_zaak_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ def test_status_handle_zaken_notification(self, m, mock_handle: Mock):
"""
data = MockAPIData().install_mocks(m)

# Added for https://taiga.maykinmedia.nl/project/open-inwoner/task/1904
# In eSuite it is possible to reuse a StatusType for multiple ZaakTypen, which
# led to errors when retrieving the ZaakTypeStatusTypeConfig. This duplicate
# config is added to verify that that issue was solved
ztc = ZaakTypeConfigFactory.create(
catalogus__url=data.zaak_type["catalogus"],
identificatie=data.zaak_type["identificatie"],
)
ZaakTypeStatusTypeConfigFactory.create(
omschrijving=data.status_type_final["omschrijving"],
statustype_url=data.status_type_final["url"],
)
ZaakTypeStatusTypeConfigFactory.create(
zaaktype_config=ztc,
omschrijving=data.status_type_final["omschrijving"],
statustype_url=data.status_type_final["url"],
)

handle_zaken_notification(data.status_notification)

mock_handle.assert_called_once()
Expand Down Expand Up @@ -299,12 +317,25 @@ def test_status_handle_notification_when_skip_informeren_is_set_and_zaaktypeconf

data = MockAPIData().install_mocks(m)

ZaakTypeConfigFactory.create(
ztc = ZaakTypeConfigFactory.create(
catalogus__url=data.zaak_type["catalogus"],
identificatie=data.zaak_type["identificatie"],
# set this to notify
notify_status_changes=True,
)
# Added for https://taiga.maykinmedia.nl/project/open-inwoner/task/1904
# In eSuite it is possible to reuse a StatusType for multiple ZaakTypen, which
# led to errors when retrieving the ZaakTypeStatusTypeConfig. This duplicate
# config is added to verify that that issue was solved
ZaakTypeStatusTypeConfigFactory.create(
omschrijving=data.status_type_final["omschrijving"],
statustype_url=data.status_type_final["url"],
)
ZaakTypeStatusTypeConfigFactory.create(
zaaktype_config=ztc,
omschrijving=data.status_type_final["omschrijving"],
statustype_url=data.status_type_final["url"],
)

handle_zaken_notification(data.status_notification)

Expand Down

0 comments on commit c243c0a

Please sign in to comment.