Skip to content

Commit

Permalink
[#2996] Retrieve questions linked to a zaak with OpenKlant
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schilling committed Feb 5, 2025
1 parent e08c90f commit 9d4ea40
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 54 deletions.
46 changes: 46 additions & 0 deletions src/open_inwoner/cms/cases/tests/test_contactform.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@
)
from open_inwoner.utils.test import ClearCachesMixin, paginated_response
from open_inwoner.utils.tests.helpers import AssertMockMatchersMixin
from openklant2.types.resources.klant_contact import KlantContactValidator

PATCHED_MIDDLEWARE = [
m
for m in settings.MIDDLEWARE
if m != "open_inwoner.kvk.middleware.KvKLoginMiddleware"
]

OPENKLANT2_ROOT = "http://localhost:8338/klantinteracties/api/v1/"


@requests_mock.Mocker()
@patch(
Expand Down Expand Up @@ -379,11 +382,43 @@ def _setUpExtraMocks(self, m):
json=self.contactmoment,
)

def _setUpOpenKlantMocks(self, m):
klantcontact = {
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"url": "http://example.com",
"gingOverOnderwerpobjecten": [],
"hadBetrokkenActoren": [],
"omvatteBijlagen": [],
"hadBetrokkenen": [],
"leiddeTotInterneTaken": [],
"nummer": "string",
"kanaal": "string",
"onderwerp": "string",
"inhoud": "string",
"indicatieContactGelukt": True,
"taal": "dut",
"vertrouwelijk": False,
"plaatsgevondenOp": "2019-08-24T14:15:22Z",
"_expand": {},
}
KlantContactValidator.validate_python(klantcontact)
m.get(
f"{OPENKLANT2_ROOT}klantcontacten?onderwerpobject__onderwerpobjectidentificatorObjectId=ZAAK-2022-0000000024",
headers={"Content-Type": "application/json"},
json={
"count": 123,
"next": None,
"previous": None,
"results": [klantcontact],
},
)

def test_form_is_shown_if_open_klant_api_configured(
self, m, mock_contactmoment, mock_send_confirm
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

self.assertTrue(self.klant_config.has_api_configuration)

Expand All @@ -400,6 +435,7 @@ def test_form_is_shown_if_open_klant_email_configured(
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

self.esuite_config.klanten_service = None
self.esuite_config.save()
Expand All @@ -423,6 +459,7 @@ def test_form_is_shown_if_open_klant_email_and_api_configured(
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

self.klant_config.register_email = "example@example.com"
self.klant_config.save()
Expand All @@ -442,6 +479,7 @@ def test_no_form_shown_if_open_klant_not_configured(
self, m, mock_contactmoment, mock_send_confirm
):
self._setUpMocks(m)
self._setUpOpenKlantMocks(m)

# reset
self.esuite_config.klanten_service = None
Expand All @@ -466,6 +504,7 @@ def test_no_form_shown_if_contact_form_disabled(
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

CatalogusConfig.objects.all().delete()
self.zaak_type_config.delete()
Expand All @@ -488,6 +527,7 @@ def test_form_success_with_api_esuite(
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

response = self.app.get(self.case_detail_url, user=self.user)
form = response.forms["contact-form"]
Expand Down Expand Up @@ -589,6 +629,7 @@ def test_form_success_missing_medewerker(
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

config = ESuiteKlantConfig.get_solo()
# empty id should be excluded from contactmoment_create_data
Expand Down Expand Up @@ -650,6 +691,7 @@ def test_form_success_with_api_eherkenning_user(
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

for use_rsin_for_innNnpId_query_parameter in [True, False]:
with self.subTest(
Expand Down Expand Up @@ -725,6 +767,7 @@ def test_form_success_with_api_eherkenning_user(
def test_form_success_with_email(self, m, mock_contactmoment, mock_send_confirm):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

self.klant_config.register_contact_email = "example@example.com"
self.klant_config.register_contact_via_api = False
Expand Down Expand Up @@ -768,6 +811,7 @@ def test_form_success_with_both_email_and_api(
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

self.klant_config.register_contact_email = "example@example.com"
self.klant_config.save()
Expand Down Expand Up @@ -806,6 +850,7 @@ def test_send_email_confirmation_is_configurable__send_enabled(
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

config = KlantenSysteemConfig.get_solo()
config.send_email_confirmation = True
Expand All @@ -826,6 +871,7 @@ def test_send_email_confirmation_is_configurable__send_disabled(
):
self._setUpMocks(m)
self._setUpExtraMocks(m)
self._setUpOpenKlantMocks(m)

config = KlantenSysteemConfig.get_solo()
config.send_email_confirmation = False
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/cms/cases/views/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def resolve_case(self, case: Zaak, group: ZGWApiGroupConfig) -> Zaak:

case.zaaktype_config = zaaktype_config

if zaaktype_config:
if zaaktype_config and case.status:
statustype_config = ZaakTypeStatusTypeConfig.objects.get(
zaaktype_config=zaaktype_config,
statustype_url=case.status.statustype.url,
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions src/open_inwoner/openzaak/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
because there is an issue where e-Suite doesn't return all JSON fields the official API and dataclasses expect
"""

# TODO: add uuid to Zaak?


@dataclass
class Zaak(ZGWModel):
Expand Down

0 comments on commit 9d4ea40

Please sign in to comment.