From 852c6aecd0bbbc0597643ddf9f705bf004c9ce67 Mon Sep 17 00:00:00 2001 From: Paul Schilling Date: Fri, 17 Jan 2025 15:03:05 +0100 Subject: [PATCH] [#2966] Add django-setup-configuration step for KlantenSysteemConfig --- .../configurations/bootstrap/openklant.py | 23 +++++++++++++--- .../klantensysteem_config_step_full.yaml | 6 +++++ .../bootstrap/test_setup_openklant_config.py | 27 +++++++++++++++---- 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 src/open_inwoner/configurations/tests/bootstrap/files/klantensysteem_config_step_full.yaml diff --git a/src/open_inwoner/configurations/bootstrap/openklant.py b/src/open_inwoner/configurations/bootstrap/openklant.py index 1c4d16ed0..84ab4c5f9 100644 --- a/src/open_inwoner/configurations/bootstrap/openklant.py +++ b/src/open_inwoner/configurations/bootstrap/openklant.py @@ -154,8 +154,25 @@ def execute(self, model: OpenKlant2Configuration): config.save() -# TODO: complete config step -class KlantSysteemConfigurationStep( +class KlantenSysteemConfigurationStep( BaseConfigurationStep[KlantSysteemConfigurationModel] ): - pass + """ + Configure the KlantenSysteem settings + """ + + verbose_name = "KlantenSysteem configuration" + enable_setting = "klantensysteem_config_enable" + namespace = "klantensysteem_config" + config_model = KlantenSysteemConfig + + def execute(self, model: KlantenApiConfigurationModel): + create_or_update_kwargs = model.model_dump() + + config = KlantenSysteemConfig.get_solo() + + for key, val in create_or_update_kwargs.items(): + setattr(config, key, val) + + config.full_clean() + config.save() diff --git a/src/open_inwoner/configurations/tests/bootstrap/files/klantensysteem_config_step_full.yaml b/src/open_inwoner/configurations/tests/bootstrap/files/klantensysteem_config_step_full.yaml new file mode 100644 index 000000000..69bf3be6e --- /dev/null +++ b/src/open_inwoner/configurations/tests/bootstrap/files/klantensysteem_config_step_full.yaml @@ -0,0 +1,6 @@ +klantensysteem_config_enable: true +klantensysteem_config: + primary_backend: esuite + register_contact_via_api: true + register_contact_email: "oip-test@test.nl" + send_email_confirmation: true diff --git a/src/open_inwoner/configurations/tests/bootstrap/test_setup_openklant_config.py b/src/open_inwoner/configurations/tests/bootstrap/test_setup_openklant_config.py index 18580abe7..3f6cd3679 100644 --- a/src/open_inwoner/configurations/tests/bootstrap/test_setup_openklant_config.py +++ b/src/open_inwoner/configurations/tests/bootstrap/test_setup_openklant_config.py @@ -6,11 +6,17 @@ from django_setup_configuration.test_utils import execute_single_step from zgw_consumers.constants import APITypes -from open_inwoner.openklant.models import ESuiteKlantConfig, OpenKlant2Config +from open_inwoner.openklant.constants import KlantenServiceType +from open_inwoner.openklant.models import ( + ESuiteKlantConfig, + KlantenSysteemConfig, + OpenKlant2Config, +) from open_inwoner.openzaak.tests.factories import ServiceFactory from ...bootstrap.openklant import ( ESuiteKlantConfigurationStep, + KlantenSysteemConfigurationStep, OpenKlant2ConfigurationStep, ) @@ -19,6 +25,9 @@ BASE_DIR = Path(__file__).parent / "files" ESUITEKLANT_CONFIG_STEP_FULL_YAML = str(BASE_DIR / "esuiteklant_config_step_full.yaml") +KLANTENSYSTEEM_CONFIG_STEP_FULL_YAML = str( + BASE_DIR / "klantensysteem_config_step_full.yaml" +) OPENKLANT2_CONFIG_STEP_FULL_YAML = str(BASE_DIR / "openklant2_config_step_full.yaml") @@ -147,8 +156,6 @@ def assert_values(): self.assertEqual(config.klanten_service, kc) self.assertEqual(config.contactmomenten_service, cmc) - # self.assertEqual(config.register_email, "admin@oip.org") - # self.assertEqual(config.register_contact_moment, True) self.assertEqual(config.register_bronorganisatie_rsin, "837194569") self.assertEqual(config.register_channel, "email") self.assertEqual(config.register_type, "bericht") @@ -162,8 +169,6 @@ def assert_values(): assert_values() config = ESuiteKlantConfig.get_solo() - # config.register_email = "not-admin@oip.org" - # config.register_contact_moment = False config.register_bronorganisatie_rsin = "800000009" config.register_channel = "not-email" config.register_type = "not-bericht" @@ -203,3 +208,15 @@ def test_configure(self): self.assertEqual( config.interne_taak_toelichting, "Vraag via OIP, graag beantwoorden" ) + + +class KlantenSysteemConfigurationStepTest(TestCase): + def test_configure(self): + breakpoint() + execute_single_step( + KlantenSysteemConfigurationStep, + yaml_source=KLANTENSYSTEEM_CONFIG_STEP_FULL_YAML, + ) + + config = KlantenSysteemConfig.get_solo() + self.assertEqual(config.primary_backend, KlantenServiceType.ESUITE.value)