From 945f4c9695596dbb792ed25fe19085584a37e295 Mon Sep 17 00:00:00 2001 From: Luisa Date: Mon, 30 Nov 2026 11:30:43 +0100 Subject: [PATCH 1/2] Allow os_field in idm_mapping.update --- meta | 2 +- .../action/actions/idm_mapping/update.py | 1 + .../system/action/idm_mapping/test_update.py | 123 +++++++++++++++++- 3 files changed, 124 insertions(+), 2 deletions(-) diff --git a/meta b/meta index ea77aa5aae..22fcbe1ffe 160000 --- a/meta +++ b/meta @@ -1 +1 @@ -Subproject commit ea77aa5aae7fbf9df0fd7dfae1763d378873bcb9 +Subproject commit 22fcbe1ffe35541e887e65d9a2d41e888c6b002d diff --git a/openslides_backend/action/actions/idm_mapping/update.py b/openslides_backend/action/actions/idm_mapping/update.py index 825af6290a..623d5e1dac 100644 --- a/openslides_backend/action/actions/idm_mapping/update.py +++ b/openslides_backend/action/actions/idm_mapping/update.py @@ -15,6 +15,7 @@ class IdmMappingUpdate(UpdateAction): schema = DefaultSchema(IdmMapping()).get_update_schema( optional_properties=[ "idm_field", + "os_field", "default_value", "allow_update", "override_default", diff --git a/tests/system/action/idm_mapping/test_update.py b/tests/system/action/idm_mapping/test_update.py index b91357f1c5..89e6acd8d7 100644 --- a/tests/system/action/idm_mapping/test_update.py +++ b/tests/system/action/idm_mapping/test_update.py @@ -26,12 +26,133 @@ def test_update_simple(self) -> None: {"idm_field": "ew_its_also_a_field", "os_field": "number", "mapper_id": 1}, ) + def test_update_multiple(self) -> None: + self.set_models( + { + "idm_mapping/2": { + "idm_field": "yup", + "os_field": "comment", + "mapper_id": 1, + }, + } + ) + response = self.request_multi( + "idm_mapping.update", + [ + { + "id":1, + "idm_field": "ew_its_also_a_field", + "os_field": "number", + }, + { + "id":2, + "idm_field": "ew_its_yet_another_field", + "os_field": "vote_weight", + }, + ], + ) + self.assert_status_code(response, 200) + self.assert_model_exists( + "idm_mapping/1", + {"idm_field": "ew_its_also_a_field", "os_field": "number", "mapper_id": 1}, + ) + self.assert_model_exists( + "idm_mapping/2", + { + "idm_field": "ew_its_yet_another_field", + "os_field": "vote_weight", + "mapper_id": 1, + }, + ) + + def test_update_multiple_same_os_field_on_same_mapper(self) -> None: + self.set_models( + { + "idm_mapping/2": { + "idm_field": "yup", + "os_field": "comment", + "mapper_id": 1, + }, + } + ) + response = self.request_multi( + "idm_mapping.update", + [ + { + "id": 1, + "idm_field": "ew_its_also_a_field", + "os_field": "number", + }, + { + "id": 2, + "idm_field": "ew_its_yet_another_field", + "os_field": "number", + }, + ], + ) + self.assert_status_code(response, 400) + assert ( + response.json["message"] + == 'idm_mapping/2: duplicate key value violates unique constraint "unique_idm_mapping_mapper_id_os_field"\nDETAIL: Key (mapper_id, os_field)=(1, number) already exists.' + ) + self.assert_model_exists("idm_mapping/1", { + "idm_field": "yo", + "os_field": "number", + "mapper_id": 1, + }) + self.assert_model_exists("idm_mapping/2", { + "idm_field": "yup", + "os_field": "comment", + "mapper_id": 1, + }) + + def test_update_multiple_same_os_field_on_different_mapper(self) -> None: + self.set_models( + { + "idm_mapper/2": {"group_external_ids": ["B"]}, + "idm_mapping/2": { + "idm_field": "yup", + "os_field": "comment", + "mapper_id": 2, + }, + } + ) + response = self.request_multi( + "idm_mapping.update", + [ + { + "id": 1, + "idm_field": "ew_its_also_a_field", + "os_field": "number", + }, + { + "id": 2, + "idm_field": "ew_its_yet_another_field", + "os_field": "number", + }, + ], + ) + self.assert_status_code(response, 200) + self.assert_model_exists( + "idm_mapping/1", + {"idm_field": "ew_its_also_a_field", "os_field": "number", "mapper_id": 1}, + ) + self.assert_model_exists( + "idm_mapping/2", + { + "idm_field": "ew_its_yet_another_field", + "os_field": "number", + "mapper_id": 2, + }, + ) + def test_update_complex(self) -> None: response = self.request( "idm_mapping.update", { "id": 1, "idm_field": "ew_its_also_a_field", + "os_field": "comment", "default_value": "I'ma default", "allow_update": True, "override_default": True, @@ -42,7 +163,7 @@ def test_update_complex(self) -> None: "idm_mapping/1", { "idm_field": "ew_its_also_a_field", - "os_field": "number", + "os_field": "comment", "mapper_id": 1, "default_value": "I'ma default", "allow_update": True, From 7edf8d849927f93a384b89216e57c18c40adc86a Mon Sep 17 00:00:00 2001 From: Luisa Date: Mon, 30 Nov 2026 11:48:16 +0100 Subject: [PATCH 2/2] Update docs --- docs/actions/idm_mapping.update.md | 1 + .../system/action/idm_mapping/test_update.py | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/docs/actions/idm_mapping.update.md b/docs/actions/idm_mapping.update.md index c84e14d66f..4bdc40efad 100644 --- a/docs/actions/idm_mapping.update.md +++ b/docs/actions/idm_mapping.update.md @@ -5,6 +5,7 @@ id: Id; // Optional idm_field: string; + os_field: string; default_value: string; allow_update: boolean; override_default: boolean; diff --git a/tests/system/action/idm_mapping/test_update.py b/tests/system/action/idm_mapping/test_update.py index 89e6acd8d7..1d5199caa5 100644 --- a/tests/system/action/idm_mapping/test_update.py +++ b/tests/system/action/idm_mapping/test_update.py @@ -40,12 +40,12 @@ def test_update_multiple(self) -> None: "idm_mapping.update", [ { - "id":1, + "id": 1, "idm_field": "ew_its_also_a_field", "os_field": "number", }, { - "id":2, + "id": 2, "idm_field": "ew_its_yet_another_field", "os_field": "vote_weight", }, @@ -95,16 +95,22 @@ def test_update_multiple_same_os_field_on_same_mapper(self) -> None: response.json["message"] == 'idm_mapping/2: duplicate key value violates unique constraint "unique_idm_mapping_mapper_id_os_field"\nDETAIL: Key (mapper_id, os_field)=(1, number) already exists.' ) - self.assert_model_exists("idm_mapping/1", { - "idm_field": "yo", - "os_field": "number", - "mapper_id": 1, - }) - self.assert_model_exists("idm_mapping/2", { - "idm_field": "yup", - "os_field": "comment", - "mapper_id": 1, - }) + self.assert_model_exists( + "idm_mapping/1", + { + "idm_field": "yo", + "os_field": "number", + "mapper_id": 1, + }, + ) + self.assert_model_exists( + "idm_mapping/2", + { + "idm_field": "yup", + "os_field": "comment", + "mapper_id": 1, + }, + ) def test_update_multiple_same_os_field_on_different_mapper(self) -> None: self.set_models(