Skip to content

Commit

Permalink
[#2966] Add django-setup-configuration step for KlantenSysteemConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schilling committed Jan 17, 2025
1 parent d3bb019 commit 852c6ae
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
23 changes: 20 additions & 3 deletions src/open_inwoner/configurations/bootstrap/openklant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -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")


Expand Down Expand Up @@ -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")
Expand All @@ -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"
Expand Down Expand Up @@ -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)

0 comments on commit 852c6ae

Please sign in to comment.