Skip to content

Commit

Permalink
✨ Add extra meta information on zaakobject if objecttype is 'overige'
Browse files Browse the repository at this point in the history
  • Loading branch information
damm89 committed Oct 24, 2024
1 parent f9114f1 commit 64c1643
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 11 deletions.
20 changes: 11 additions & 9 deletions src/bptl/work_units/zgw/objects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ def filter_zaakobjects_on_objecttype_label(task: BaseTask) -> List[Dict]:
filtered_objects = []
for zo in zaakobjects:
if object := objects.get(zo["object"]):
filtered_objects.append(
{
"objectUrl": object["url"],
"objectType": object["type"],
"objectTypeOverige": zo.get("objectTypeOverige", ""),
"relatieomschrijving": zo.get("relatieomschrijving", ""),
}
)

fobj = {
"objectUrl": object["url"],
"objectType": zo["objectType"],
"relatieomschrijving": zo.get("relatieomschrijving", ""),
}
if zo["objectType"] == "overige":
fobj["objectTypeOverige"] = zo.get("objectTypeOverige", "")
fobj["objectTypeOverigeDefinitie"] = zo.get(
"objectTypeOverigeDefinitie", {}
)
filtered_objects.append(fobj)
return {"filteredObjects": filtered_objects}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ def test_objecttypes_empty_label(self, m):
{
"filteredObjects": [
{
"objectType": REVIEW_OBJECTTYPE["url"],
"objectTypeOverige": zaakobject["objectTypeOverige"],
"objectType": zaakobject["objectType"],
"objectUrl": REVIEW_OBJECT["url"],
"relatieomschrijving": zaakobject["relatieomschrijving"],
}
Expand Down Expand Up @@ -200,3 +199,49 @@ def test_objecttypes_mismatch_label(self, m):
zaakobjects,
{"filteredObjects": []},
)

def test_objecttypes_empty_label_objecttype_is_overige(self, m):
mock_service_oas_get(m, OBJECTS_ROOT, "objects")
mock_service_oas_get(m, OBJECTTYPES_ROOT, "objecttypes")
m.get(
f"{OBJECTTYPES_ROOT}objecttypes",
json=[REVIEW_OBJECTTYPE],
)
m.get(f"{REVIEW_OBJECT['url']}", json=REVIEW_OBJECT)
zaakobject = generate_oas_component(
"zrc",
"schemas/ZaakObject",
zaak=ZAAK_URL,
object=REVIEW_OBJECT["url"],
objectType="overige",
)
task_dict = {
"topic_name": "some-topic-name",
"worker_id": "test-worker-id",
"task_id": "test-task-id",
"variables": {
"bptlAppId": serialize_variable("some-app-id"),
"zaakObjects": serialize_variable([zaakobject]),
"label": serialize_variable(""),
},
}
task = ExternalTask.objects.create(
**task_dict,
)
zaakobjects = filter_zaakobjects_on_objecttype_label(task)
self.assertEqual(
zaakobjects,
{
"filteredObjects": [
{
"objectType": zaakobject["objectType"],
"objectTypeOverige": zaakobject["objectTypeOverige"],
"objectTypeOverigeDefinitie": zaakobject[
"objectTypeOverigeDefinitie"
],
"objectUrl": REVIEW_OBJECT["url"],
"relatieomschrijving": zaakobject["relatieomschrijving"],
}
]
},
)

0 comments on commit 64c1643

Please sign in to comment.