Skip to content

Commit

Permalink
Merge pull request #235 from GemeenteUtrecht/bug/fix-checklist-initia…
Browse files Browse the repository at this point in the history
…lization

🐛 Fix bug where neither catalogusDomein nor zaaktypeCatalogus are…
  • Loading branch information
damm89 authored Feb 8, 2024
2 parents 7f35309 + 28cb3e6 commit 51d5504
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/bptl/work_units/zgw/objects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from zgw_consumers.concurrent import parallel
from zgw_consumers.constants import APITypes

from bptl.tasks.base import check_variable
from bptl.tasks.base import MissingVariable, check_variable
from bptl.tasks.registry import register
from bptl.work_units.zgw.tasks.base import ZGWWorkUnit, require_zrc, require_ztc

Expand All @@ -31,7 +31,7 @@ class InitializeChecklistTask(ZGWWorkUnit):
**Required process variables**
* ``zaakUrl`` [str]: URL-reference of the ZAAK in Open Zaak.
* ``catalogusDomein`` [str]: `domein` of the CATALOGUS in Open Zaak.
* ``catalogusDomein`` [str]: `domein` of the CATALOGUS in Open Zaak OR ``zaaktypeCatalogus`` [str]: URL-reference of CATALOGUS in CATALOGUS of Open Zaak.
* ``zaaktypeIdentificatie`` [str]: URL-reference of ZAAKTYPE in CATALOGUS of Open Zaak.
**Sets the process variables**
Expand All @@ -42,7 +42,19 @@ class InitializeChecklistTask(ZGWWorkUnit):

def check_if_checklisttype_does_not_exist(self, variables: Dict) -> bool:
# Check if checklisttype exists
catalogus_domein = check_variable(variables, "catalogusDomein")
catalogus_domein = variables.get("catalogusDomein", None)
if not catalogus_domein:
catalogus_url = variables.get("zaaktypeCatalogus", None)
if catalogus_url:
ztc_client = self.get_client(APITypes.ztc)
catalogus = ztc_client.retrieve("catalogus", url=catalogus_url)
catalogus_domein = catalogus.get("domein", None)

if not catalogus_domein:
raise MissingVariable(
"The variables `catalogusDomein` and `zaaktypeCatalogus` are missing or empty. Please supply either one."
)

zaaktype_identificatie = check_variable(variables, "zaaktypeIdentificatie")
checklisttype = fetch_checklisttype(
self.task, catalogus_domein, zaaktype_identificatie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def test_missing_variable(self, m):
with self.assertRaises(MissingVariable) as exc:
task.perform()
self.assertEqual(
exc.exception.args[0], "The variable catalogusDomein is missing or empty."
exc.exception.args[0],
"The variables `catalogusDomein` and `zaaktypeCatalogus` are missing or empty. Please supply either one.",
)

def test_missing_checklisttype(self, m):
Expand Down

0 comments on commit 51d5504

Please sign in to comment.