Skip to content

Commit

Permalink
✅ [open-zaak/open-notificaties#156] Fix tests for new zaaktype.catalo…
Browse files Browse the repository at this point in the history
…gus kenmerk
  • Loading branch information
stevenbal committed Dec 17, 2024
1 parent 48804fd commit d53b4be
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/openzaak/components/catalogi/admin/admin_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def auto_publish(self, request):

def send_notification(self, context_request):

viewset = ZaakTypeViewSet()
viewset = ZaakTypeViewSet(request=self.request)
viewset.action = "update"

reference_object = self.object
Expand Down
2 changes: 1 addition & 1 deletion src/openzaak/components/catalogi/admin/side_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def create_new_version(self):
class NotificationSideEffect(SideEffectBase):
def apply(self):
viewset_cls = VIEWSET_FOR_MODEL[type(self.original)]
viewset = viewset_cls()
viewset = viewset_cls(request=self.request)

send_notification = False
is_create = (
Expand Down
2 changes: 1 addition & 1 deletion src/openzaak/components/zaken/api/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class ZaakViewSet(
"""

queryset = (
Zaak.objects.select_related("_zaaktype")
Zaak.objects.select_related("_zaaktype", "_zaaktype__catalogus")
.prefetch_related(
"deelzaken",
models.Prefetch(
Expand Down
22 changes: 19 additions & 3 deletions src/openzaak/components/zaken/tests/test_notifications_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from vng_api_common.models import JWTSecret
from vng_api_common.tests import reverse
from zgw_consumers.constants import APITypes
from zgw_consumers.models import Service
from zgw_consumers.test.factories import ServiceFactory

from openzaak.components.besluiten.tests.factories import BesluitFactory
from openzaak.components.catalogi.tests.factories import (
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_send_notif_create_zaak_external_zaaktype(self, mock_notif):
Check if the zaaktype.catalogus kenmerk is correctly sent if the Zaak
has an external zaaktype
"""
Service.objects.create(
ServiceFactory.create(
api_root="https://externe.catalogus.nl/api/v1/", api_type=APITypes.ztc
)

Expand Down Expand Up @@ -185,7 +185,7 @@ def test_send_notif_create_zaak_external_zaaktype_failed_to_fetch_catalogus(
Check if the zaaktype.catalogus kenmerk is left empty sent if the Zaak
has an external zaaktype and the Catalogus could not be fetched
"""
Service.objects.create(
ServiceFactory.create(
api_root="https://externe.catalogus.nl/api/v1/", api_type=APITypes.ztc
)

Expand Down Expand Up @@ -270,6 +270,7 @@ def test_send_notif_delete_resultaat(self, mock_notif):
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{zaaktype_url}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
},
Expand Down Expand Up @@ -299,6 +300,7 @@ def test_send_notif_update_zaakobject(self, mock_notif):
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
},
Expand Down Expand Up @@ -330,6 +332,7 @@ def test_send_notif_update_zaak_eigenschap(self, mock_notif):
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
},
Expand Down Expand Up @@ -379,6 +382,7 @@ def test_zaak_create_fail_send_notification_create_db_entry(self, m, mock_notif)
"kenmerken": {
"bronorganisatie": data["bronorganisatie"],
"zaaktype": f"http://testserver{zaaktype_url}",
"zaaktype.catalogus": f"http://testserver{reverse(zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": data["vertrouwelijkheidaanduiding"],
},
"resource": "zaak",
Expand Down Expand Up @@ -419,6 +423,7 @@ def test_zaak_delete_fail_send_notification_create_db_entry(self, m, mock_notif)
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
"resource": "zaak",
Expand Down Expand Up @@ -476,6 +481,7 @@ def test_status_create_fail_send_notification_create_db_entry(self, m, mock_noti
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
"resource": "status",
Expand Down Expand Up @@ -530,6 +536,7 @@ def test_zaakobject_create_fail_send_notification_create_db_entry(
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
"resource": "zaakobject",
Expand Down Expand Up @@ -587,6 +594,7 @@ def test_zaakinformatieobject_create_fail_send_notification_create_db_entry(
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
"resource": "zaakinformatieobject",
Expand Down Expand Up @@ -631,6 +639,7 @@ def test_zaakinformatieobject_delete_fail_send_notification_create_db_entry(
"kenmerken": {
"bronorganisatie": zio.zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zio.zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zio.zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zio.zaak.vertrouwelijkheidaanduiding,
},
"resource": "zaakinformatieobject",
Expand Down Expand Up @@ -682,6 +691,7 @@ def test_zaakeigenschap_create_fail_send_notification_create_db_entry(
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
"resource": "zaakeigenschap",
Expand Down Expand Up @@ -731,6 +741,7 @@ def test_klantcontact_create_fail_send_notification_create_db_entry(
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
"resource": "klantcontact",
Expand Down Expand Up @@ -790,6 +801,7 @@ def test_rol_create_fail_send_notification_create_db_entry(self, m, mock_notif):
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
"resource": "rol",
Expand Down Expand Up @@ -831,6 +843,7 @@ def test_rol_delete_fail_send_notification_create_db_entry(self, m, mock_notif):
"kenmerken": {
"bronorganisatie": rol.zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(rol.zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(rol.zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": rol.zaak.vertrouwelijkheidaanduiding,
},
"resource": "rol",
Expand Down Expand Up @@ -884,6 +897,7 @@ def test_resultaat_create_fail_send_notification_create_db_entry(
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
"resource": "resultaat",
Expand Down Expand Up @@ -927,6 +941,7 @@ def test_resultaat_delete_fail_send_notification_create_db_entry(
"kenmerken": {
"bronorganisatie": resultaat.zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(resultaat.zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(resultaat.zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": resultaat.zaak.vertrouwelijkheidaanduiding,
},
"resource": "resultaat",
Expand Down Expand Up @@ -973,6 +988,7 @@ def test_zaakbesluit_create_fail_send_notification_create_db_entry(
"kenmerken": {
"bronorganisatie": besluit.zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(besluit.zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(besluit.zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": besluit.zaak.vertrouwelijkheidaanduiding,
},
"resource": "zaakbesluit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_zaakinformatieobject_create_fail_send_notification_create_db_entry(
"kenmerken": {
"bronorganisatie": zaak.bronorganisatie,
"zaaktype": f"http://testserver{reverse(zaak.zaaktype)}",
"zaaktype.catalogus": f"http://testserver{reverse(zaak.zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding,
},
"resource": "zaakinformatieobject",
Expand Down
2 changes: 2 additions & 0 deletions src/openzaak/notifications/tests/test_notification_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_notificatie_client_error_retry(self, m, retry_mock, mock_notif):
"kenmerken": {
"bronorganisatie": "517439943",
"zaaktype": f"http://testserver{zaaktype_url}",
"zaaktype.catalogus": f"http://testserver{reverse(zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduiding.openbaar,
},
}
Expand Down Expand Up @@ -141,6 +142,7 @@ def test_notificatie_client_error_final_retry(self, m, retry_mock, mock_notif):
"kenmerken": {
"bronorganisatie": "517439943",
"zaaktype": f"http://testserver{zaaktype_url}",
"zaaktype.catalogus": f"http://testserver{reverse(zaaktype.catalogus)}",
"vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduiding.openbaar,
},
}
Expand Down
1 change: 1 addition & 0 deletions src/openzaak/notifications/tests/test_register_kanaal.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def test_kanaal_create_without_name(self, mock_get_client):
"filters": [
"bronorganisatie",
"zaaktype",
"zaaktype.catalogus",
"vertrouwelijkheidaanduiding",
],
},
Expand Down

0 comments on commit d53b4be

Please sign in to comment.