Skip to content

Commit

Permalink
👽 [#4788] Changes according to setup-configuration lib changes
Browse files Browse the repository at this point in the history
* setup_configuration now only takes one yaml file as a source
* change testing utils
  • Loading branch information
stevenbal committed Nov 21, 2024
1 parent 4ff2c83 commit 03741fe
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 53 deletions.
4 changes: 1 addition & 3 deletions bin/setup_configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ if [[ "${RUN_SETUP_CONFIG,,}" =~ ^(true|1|yes)$ ]]; then
${SCRIPTPATH}/wait_for_db.sh

src/manage.py migrate
src/manage.py setup_configuration \
--yaml-file data/services.yaml \
--yaml-file data/objects_api.yaml
src/manage.py setup_configuration --yaml-file setup_configuration/data.yaml
fi
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ services:
volumes: &web_volumes
- media:/app/media
- private_media:/app/private_media
- ./docker/setup_configuration:/app/data
- ./docker/setup_configuration:/app/setup_configuration
- log:/app/log
- certifi_ca_bundle:/app/certifi_ca_bundle
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,28 @@ zgw_consumers:
auth_type: zgw
client_id: test_client_id
secret: test_secret_key

objects_api_config_enable: True
objects_api:
groups:
- name: Config 1
identifier: config-1
objects_service_identifier: objecten-test
objecttypes_service_identifier: objecttypen-test
drc_service_identifier: documenten-test
catalogi_service_identifier: catalogi-test
catalogue_domain: TEST
catalogue_rsin: "000000000"
organisatie_rsin: "000000000"
iot_submission_report: PDF Informatieobjecttype
iot_submission_csv: CSV Informatieobjecttype
iot_attachment: Attachment Informatieobjecttype
- name: Config 2
identifier: config-2
objects_service_identifier: objecten-test
objecttypes_service_identifier: objecttypen-test
drc_service_identifier: documenten-test
catalogi_service_identifier: catalogi-test
catalogue_domain: OTHER
catalogue_rsin: "000000000"
organisatie_rsin: "000000000"
24 changes: 0 additions & 24 deletions docker/setup_configuration/objects_api.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.test import TestCase

from django_setup_configuration.test_utils import load_step_config_from_source
from django_setup_configuration.test_utils import execute_single_step
from zgw_consumers.constants import APITypes, AuthTypes
from zgw_consumers.test.factories import ServiceFactory

Expand All @@ -21,10 +21,6 @@
)


def get_config_model(path):
return load_step_config_from_source(ObjectsAPIConfigurationStep, path)


class ObjectsAPIConfigurationStepTests(TestCase):
maxDiff = None

Expand Down Expand Up @@ -69,10 +65,7 @@ def setUp(self):
)

def test_execute_success(self):
step_config_model = get_config_model(CONFIG_FILE_PATH)
step = ObjectsAPIConfigurationStep()

step.execute(step_config_model)
execute_single_step(ObjectsAPIConfigurationStep, CONFIG_FILE_PATH)

self.assertEqual(ObjectsAPIGroupConfig.objects.count(), 2)

Expand Down Expand Up @@ -107,10 +100,7 @@ def test_execute_success(self):
def test_execute_update_existing_config(self):
ObjectsAPIGroupConfigFactory.create(name="old name", identifier="config-1")

step_config_model = get_config_model(CONFIG_FILE_PATH)
step = ObjectsAPIConfigurationStep()

step.execute(step_config_model)
execute_single_step(ObjectsAPIConfigurationStep, CONFIG_FILE_PATH)

self.assertEqual(ObjectsAPIGroupConfig.objects.count(), 2)

Expand Down Expand Up @@ -143,10 +133,9 @@ def test_execute_update_existing_config(self):
self.assertEqual(config2.iot_attachment, "")

def test_execute_with_required_fields(self):
step_config_model = get_config_model(CONFIG_FILE_PATH_REQUIRED_FIELDS)
step = ObjectsAPIConfigurationStep()

step.execute(step_config_model)
execute_single_step(
ObjectsAPIConfigurationStep, CONFIG_FILE_PATH_REQUIRED_FIELDS
)

self.assertEqual(ObjectsAPIGroupConfig.objects.count(), 1)

Expand All @@ -167,10 +156,7 @@ def test_execute_with_required_fields(self):
self.assertEqual(config.iot_attachment, "")

def test_execute_with_all_fields(self):
step_config_model = get_config_model(CONFIG_FILE_PATH_ALL_FIELDS)
step = ObjectsAPIConfigurationStep()

step.execute(step_config_model)
execute_single_step(ObjectsAPIConfigurationStep, CONFIG_FILE_PATH_ALL_FIELDS)

self.assertEqual(ObjectsAPIGroupConfig.objects.count(), 1)

Expand All @@ -190,8 +176,6 @@ def test_execute_with_all_fields(self):
self.assertEqual(config.iot_attachment, "Attachment Informatieobjecttype")

def test_execute_is_idempotent(self):
step_config_model = get_config_model(CONFIG_FILE_PATH_ALL_FIELDS)
step = ObjectsAPIConfigurationStep()

def make_assertions():
self.assertEqual(ObjectsAPIGroupConfig.objects.count(), 1)
Expand All @@ -211,10 +195,10 @@ def make_assertions():
self.assertEqual(config.iot_submission_csv, "CSV Informatieobjecttype")
self.assertEqual(config.iot_attachment, "Attachment Informatieobjecttype")

step.execute(step_config_model)
execute_single_step(ObjectsAPIConfigurationStep, CONFIG_FILE_PATH_ALL_FIELDS)

make_assertions()

step.execute(step_config_model)
execute_single_step(ObjectsAPIConfigurationStep, CONFIG_FILE_PATH_ALL_FIELDS)

make_assertions()

0 comments on commit 03741fe

Please sign in to comment.