-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2966] Add django-setup-configuration step for KlantenSysteemConfig
- Loading branch information
Paul Schilling
committed
Jan 21, 2025
1 parent
390ba0a
commit 913b67a
Showing
3 changed files
with
75 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/open_inwoner/configurations/tests/bootstrap/files/klantensysteem_config_step_full.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "[email protected]" | ||
send_email_confirmation: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
from pathlib import Path | ||
|
||
from django.core.exceptions import ValidationError | ||
from django.test import TestCase | ||
|
||
from django_setup_configuration.exceptions import ConfigurationRunFailed | ||
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 +26,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 +157,6 @@ def assert_values(): | |
self.assertEqual(config.klanten_service, kc) | ||
self.assertEqual(config.contactmomenten_service, cmc) | ||
|
||
# self.assertEqual(config.register_email, "[email protected]") | ||
# 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 +170,6 @@ def assert_values(): | |
assert_values() | ||
|
||
config = ESuiteKlantConfig.get_solo() | ||
# config.register_email = "[email protected]" | ||
# config.register_contact_moment = False | ||
config.register_bronorganisatie_rsin = "800000009" | ||
config.register_channel = "not-email" | ||
config.register_type = "not-bericht" | ||
|
@@ -203,3 +209,39 @@ def test_configure(self): | |
self.assertEqual( | ||
config.interne_taak_toelichting, "Vraag via OIP, graag beantwoorden" | ||
) | ||
|
||
|
||
class KlantenSysteemConfigurationStepTest(TestCase): | ||
def test_configure_success(self): | ||
kc = ServiceFactory( | ||
slug="klanten-service", | ||
api_root=KLANTEN_SERVICE_API_ROOT, | ||
api_type=APITypes.kc, | ||
) | ||
cmc = ServiceFactory( | ||
slug="contactmomenten-service", | ||
api_root=CONTACTMOMENTEN_SERVICE_API_ROOT, | ||
api_type=APITypes.cmc, | ||
) | ||
esuite_config = ESuiteKlantConfig.get_solo() | ||
esuite_config.klanten_service = kc | ||
esuite_config.contactmomenten_service = cmc | ||
esuite_config.save() | ||
|
||
execute_single_step( | ||
KlantenSysteemConfigurationStep, | ||
yaml_source=KLANTENSYSTEEM_CONFIG_STEP_FULL_YAML, | ||
) | ||
|
||
config = KlantenSysteemConfig.get_solo() | ||
self.assertEqual(config.primary_backend, KlantenServiceType.ESUITE.value) | ||
self.assertTrue(config.register_contact_via_api) | ||
self.assertEqual(config.register_contact_email, "[email protected]") | ||
self.assertTrue(config.send_email_confirmation) | ||
|
||
def test_configure_missing_api_services(self): | ||
with self.assertRaises(ValidationError): | ||
execute_single_step( | ||
KlantenSysteemConfigurationStep, | ||
yaml_source=KLANTENSYSTEEM_CONFIG_STEP_FULL_YAML, | ||
) |