Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix bug where neither catalogusDomein nor zaaktypeCatalogus are… #235

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading