Skip to content

Commit

Permalink
[#2640] Update tests to check long case result description
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Aug 5, 2024
1 parent c57f14d commit 292d399
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 14 deletions.
14 changes: 13 additions & 1 deletion src/open_inwoner/cms/cases/tests/test_contactform.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,23 @@ def setUp(self):
volgnummer=1,
isEindstatus=True,
)
self.resultaattype_with_naam = generate_oas_component_cached(
"ztc",
"schemas/ResultaatType",
url=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
zaaktype=self.zaaktype["url"],
omschrijving="Short description",
resultaattypeomschrijving="http://example.com",
selectielijstklasse="http://example.com",
naam="Long description (>20 chars) of result",
)
self.result = generate_oas_component_cached(
"zrc",
"schemas/Resultaat",
uuid="a44153aa-ad2c-6a07-be75-15add5113",
url=self.zaak["resultaat"],
resultaattype=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
# resultaattype=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
resultaattype=self.resultaattype_with_naam["url"],
zaak=self.zaak["url"],
toelichting="resultaat toelichting",
)
Expand Down Expand Up @@ -260,6 +271,7 @@ def _setUpMocks(self, m):
for resource in [
self.zaak,
self.result,
self.resultaattype_with_naam,
self.zaaktype,
self.status_finish,
self.status_type_finish,
Expand Down
13 changes: 12 additions & 1 deletion src/open_inwoner/cms/cases/tests/test_htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,22 @@ def setUp(self) -> None:
"geslachtsnaam": "Bazz",
},
)
self.resultaattype_with_naam = generate_oas_component_cached(
"ztc",
"schemas/ResultaatType",
url=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
zaaktype=self.zaaktype["url"],
omschrijving="Short description",
resultaattypeomschrijving="http://example.com",
selectielijstklasse="http://example.com",
naam="Long description (>20 chars) of result",
)
self.result = generate_oas_component_cached(
"zrc",
"schemas/Resultaat",
uuid="a44153aa-ad2c-6a07-be75-15add5113",
url=self.zaak["resultaat"],
resultaattype=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
resultaattype=self.resultaattype_with_naam["url"],
zaak=self.zaak["url"],
toelichting="resultaat toelichting",
)
Expand Down Expand Up @@ -324,6 +334,7 @@ def _setUpMocks(self, m):

for resource in [
self.zaak,
self.resultaattype_with_naam,
self.result,
self.zaaktype,
self.status_type_new,
Expand Down
24 changes: 20 additions & 4 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ def get_context_data(self, **kwargs):
end_statustype=self.handle_end_statustype(statuses, statustypen),
)
result_data = self.get_result_data(
self.case, self.resulttype_config_mapping, zaken_client
self.case,
self.resulttype_config_mapping,
zaken_client,
catalogi_client,
)

hooks.case_status_seen(self.request.user, self.case)
Expand Down Expand Up @@ -526,15 +529,28 @@ def get_upload_info_context(self, case: Zaak):

@staticmethod
def get_result_data(
case: Zaak, result_type_config_mapping: dict, client: ZakenClient
case: Zaak,
result_type_config_mapping: dict,
zaken_client: ZakenClient,
catalogi_client: CatalogiClient,
) -> dict:
"""
Get display and description for the result of `case`
Note:
For the description, we try the `esuite_compat_naam` attribute of the corresponding
resultaattype first. This is for E-suite compatibility in case the E-suite returns
a description longer than 20 chars. Alternatively, we get the description from the
config of the resultaattype.
"""
if not case.resultaat:
return {}

result = client.fetch_single_result(case.resultaat)
result = zaken_client.fetch_single_result(case.resultaat)
result_type = catalogi_client.fetch_single_resultaat_type(result.resultaattype)

display = result.toelichting
description = getattr(
description = getattr(result_type, "esuite_compat_naam", "") or getattr(
result_type_config_mapping.get(result.resultaattype), "description", ""
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def test_cms_ssd_override_settings(self):

self.assertTrue(benefits_page_is_published())

# import pdbr;pdbr.set_trace()
# check common extension
page = Page.objects.get(publisher_is_draft=False)
extension = page.commonextension
Expand Down
3 changes: 2 additions & 1 deletion src/open_inwoner/openzaak/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ class ResultaatType(ZGWModel):
brondatum_archiefprocedure: Optional[dict] = None

# E-suite compatibility
naam: str = "" # for result description ("omschrijving") with >20 chars
# result description ("omschrijving") with >20 chars
esuite_compat_naam: str = ""


@dataclass
Expand Down
8 changes: 8 additions & 0 deletions src/open_inwoner/openzaak/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
UserCaseStatusNotification,
ZaakTypeConfig,
ZaakTypeInformatieObjectTypeConfig,
ZaakTypeResultaatTypeConfig,
ZaakTypeStatusTypeConfig,
ZGWApiGroupConfig,
)
Expand Down Expand Up @@ -90,6 +91,13 @@ class Meta:
model = ZaakTypeConfig


class ZaakTypeResultaatTypeConfigFactory(factory.django.DjangoModelFactory):
zaaktype_config = factory.SubFactory(ZaakTypeConfigFactory)

class Meta:
model = ZaakTypeResultaatTypeConfig


class ZaakTypeInformatieObjectTypeConfigFactory(factory.django.DjangoModelFactory):
zaaktype_config = factory.SubFactory(ZaakTypeConfigFactory)
informatieobjecttype_url = factory.Faker("url")
Expand Down
31 changes: 25 additions & 6 deletions src/open_inwoner/openzaak/tests/test_case_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from open_inwoner.openzaak.tests.factories import (
ZaakTypeConfigFactory,
ZaakTypeInformatieObjectTypeConfigFactory,
ZaakTypeResultaatTypeConfigFactory,
ZaakTypeStatusTypeConfigFactory,
)
from open_inwoner.utils.test import (
Expand Down Expand Up @@ -127,7 +128,7 @@ def setUp(self):

#
# Catalogi API (ZTC)
# https://test.openzaak.nl/catalogi/api/v1/schema/
# https://vng-realisatie.github.io/gemma-zaken/standaard/catalogi/
#
self.zaaktype = generate_oas_component_cached(
"ztc",
Expand Down Expand Up @@ -223,10 +224,20 @@ def setUp(self):
richting="inkomend",
statustype=self.status_type_finish,
)
self.resultaattype_with_naam = generate_oas_component_cached(
"ztc",
"schemas/ResultaatType",
url=f"{CATALOGI_ROOT}resultaattypen/3dc5e2d3-ed72-41ec-a91e-000f72a7b291",
zaaktype=self.zaaktype["url"],
omschrijving="Short description",
resultaattypeomschrijving="http://example.com",
selectielijstklasse="http://example.com",
esuite_compat_naam="Long description (>20 chars) of result",
)

#
# Documenten API (DRC)
# https://test.openzaak.nl/documenten/api/v1/schema/
# https://vng-realisatie.github.io/gemma-zaken/standaard/documenten/
#
self.informatie_object = generate_oas_component_cached(
"drc",
Expand Down Expand Up @@ -295,7 +306,7 @@ def setUp(self):

#
# Zaken API (ZRC)
# https://test.openzaak.nl/zaken/api/v1/schema/
# https://vng-realisatie.github.io/gemma-zaken/standaard/zaken/
#
self.zaak = generate_oas_component_cached(
"zrc",
Expand Down Expand Up @@ -428,7 +439,7 @@ def setUp(self):
"schemas/Resultaat",
uuid="a44153aa-ad2c-6a07-be75-15add5113",
url=self.zaak["resultaat"],
resultaattype=f"{CATALOGI_ROOT}resultaattypen/b1a268dd-4322-47bb-a930-b83066b4a32c",
resultaattype=self.resultaattype_with_naam["url"],
zaak=self.zaak["url"],
toelichting="resultaat toelichting",
)
Expand Down Expand Up @@ -594,6 +605,7 @@ def _setUpMocks(self, m, use_eindstatus=True):
self.informatie_object,
self.informatie_object_2,
self.informatie_object_invisible,
self.resultaattype_with_naam,
self.zaaktype_informatie_object_type,
self.status_type_new,
self.status_type_in_behandeling,
Expand Down Expand Up @@ -726,6 +738,13 @@ def test_status_is_retrieved_when_user_logged_in_via_digid(
case_link_text="Bekijk aanvraag",
)

ZaakTypeResultaatTypeConfigFactory.create(
zaaktype_config=self.zaaktype_config,
resultaattype_url=self.resultaattype_with_naam["url"],
omschrijving=self.resultaattype_with_naam["omschrijving"],
zaaktype_uuids=[self.zaaktype["uuid"]],
)

self._setUpMocks(m)
status_new_obj, status_finish_obj = factory(
Status, [self.status_new, self.status_finish]
Expand Down Expand Up @@ -779,7 +798,7 @@ def test_status_is_retrieved_when_user_logged_in_via_digid(
],
"initiator": "Foo Bar van der Bazz",
"result": "resultaat toelichting",
"result_description": "",
"result_description": "Long description (>20 chars) of result",
"case_type_config_description": "",
"case_type_document_upload_description": "",
"internal_upload_enabled": False,
Expand Down Expand Up @@ -901,7 +920,7 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m):
],
"initiator": "Foo Bar van der Bazz",
"result": "resultaat toelichting",
"result_description": "",
"result_description": "Long description (>20 chars) of result",
"case_type_config_description": "",
"case_type_document_upload_description": "",
"internal_upload_enabled": False,
Expand Down

0 comments on commit 292d399

Please sign in to comment.