Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #81 from minvws/fix/overwrite-settings-when-cloning
Browse files Browse the repository at this point in the history
Overwrite settings when cloning
  • Loading branch information
underdarknl authored Jan 31, 2023
2 parents d1849aa + 8fcbb2e commit 31ceff9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
dockerfile: nl-kat-boefjes/Dockerfile.dev
args:
- ENVIRONMENT=dev
command: sh -c 'python -m pytest -vv boefjes/katalogus/tests/integration'
command: sh -c 'python -m pytest -v boefjes/katalogus/tests/integration'
depends_on:
- ci_katalogus-db
env_file:
Expand Down
6 changes: 6 additions & 0 deletions boefjes/katalogus/dependencies/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ def clone_settings_to_organisation(self, from_organisation: str, to_organisation
self.update_by_id(repository_id, plugin_id, to_organisation, enabled=False)

for plugin in self.get_all(from_organisation):
old_settings = self.get_all_settings(to_organisation, plugin.id)

for key, value in self.get_all_settings(from_organisation, plugin.id).items():
if key in old_settings:
self.update_setting_by_key(key, value, to_organisation, plugin.id)
continue

self.create_setting(key, value, to_organisation, plugin.id)

for repository_id, plugins in self.plugin_enabled_store.get_all_enabled(from_organisation).items():
Expand Down
3 changes: 2 additions & 1 deletion boefjes/katalogus/tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ def test_clone_settings(self):
new_org_id = "org2"
org2 = Organisation(id=new_org_id, name="Second test Organisation")
self.client.post("/v1/organisations/", org2.json())
self.client.post(f"/v1/organisations/{new_org_id}/{plug}/settings/test_key", json={"value": "second value"})

# Show that the second organisation has no settings and dns-records is not enabled
assert self.client.get(f"/v1/organisations/{new_org_id}/{plug}/settings").json() == {}
assert self.client.get(f"/v1/organisations/{new_org_id}/{plug}/settings").json() == {"test_key": "second value"}
assert self.client.get(f"/v1/organisations/{new_org_id}/plugins/{plug}").json()["enabled"] is False

# Enable two boefjes that should get disabled by the cloning
Expand Down

0 comments on commit 31ceff9

Please sign in to comment.