Skip to content

Commit

Permalink
Make notifications_api_service_identifier required on NotificationCon…
Browse files Browse the repository at this point in the history
…figurationModel
  • Loading branch information
swrichards committed Dec 12, 2024
1 parent 6687e99 commit 57363d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/setup_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ Example file:
- Foo
- Bar
If the ``notifications_api_service_identifier`` is specified, it might also be useful
Because ``notifications_api_service_identifier`` is required, it might also be useful
to use the `ServiceConfigurationStep <https://zgw-consumers.readthedocs.io/en/latest/setup_config.html>`_
from ``zgw-consumers``.
from ``zgw-consumers`` to configure the ``Service`` object for the notifications API.

Note that the ``uuid`` field in your subscriptions config must point to an existing
``Abonnement`` in the Open Notificaties service configured through ``notifications_config``.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

class NotificationConfigurationModel(ConfigurationModel):
notifications_api_service_identifier: str = DjangoModelRef(
NotificationsConfig, "notifications_api_service", default=""
NotificationsConfig,
"notifications_api_service",
)

class Meta:
Expand Down
18 changes: 9 additions & 9 deletions tests/test_configuration_steps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from django_setup_configuration.exceptions import PrerequisiteFailed
from django_setup_configuration.test_utils import execute_single_step
from zgw_consumers.test.factories import ServiceFactory

Expand Down Expand Up @@ -57,17 +58,16 @@ def test_execute_configuration_step_update_existing():

@pytest.mark.django_db
def test_execute_configuration_step_without_service_success():
execute_single_step(
NotificationConfigurationStep, yaml_source=CONFIG_FILE_PATH_NO_SERVICE
with pytest.raises(PrerequisiteFailed) as excinfo:
execute_single_step(
NotificationConfigurationStep, yaml_source=CONFIG_FILE_PATH_NO_SERVICE
)

assert (
"notifications_config.notifications_api_service_identifier\n Input should be a valid string"
in str(excinfo.value)
)

config = NotificationsConfig.get_solo()

assert config.notifications_api_service is None
assert config.notification_delivery_max_retries == 1
assert config.notification_delivery_retry_backoff == 2
assert config.notification_delivery_retry_backoff_max == 3


@pytest.mark.django_db
def test_execute_configuration_step_idempotent():
Expand Down

0 comments on commit 57363d4

Please sign in to comment.