diff --git a/openslides_backend/action/mixins/linear_sort_mixin.py b/openslides_backend/action/mixins/linear_sort_mixin.py index a2faef169..a54639700 100644 --- a/openslides_backend/action/mixins/linear_sort_mixin.py +++ b/openslides_backend/action/mixins/linear_sort_mixin.py @@ -25,10 +25,14 @@ def sort_linear( valid_instance_ids = [] for id_ in nodes: if id_ not in db_instances: - raise ActionException(f"Id {id_} not in db_instances.") + raise ActionException( + f"{self.model.collection} sorting failed, because element {self.model.collection}/{id_} doesn't exist." + ) valid_instance_ids.append(id_) if len(valid_instance_ids) != len(db_instances): - raise ActionException("Additional db_instances found.") + raise ActionException( + f"{self.model.collection} sorting failed, because some elements were not included in the call." + ) weight = 1 for id_ in valid_instance_ids: diff --git a/tests/system/action/assignment_candidate/test_sort.py b/tests/system/action/assignment_candidate/test_sort.py index f142f3d06..1088504a5 100644 --- a/tests/system/action/assignment_candidate/test_sort.py +++ b/tests/system/action/assignment_candidate/test_sort.py @@ -101,7 +101,10 @@ def test_sort_missing_model(self) -> None: {"assignment_id": 222, "candidate_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Id 32 not in db_instances." in response.json["message"] + assert ( + "assignment_candidate sorting failed, because element assignment_candidate/32 doesn't exist." + in response.json["message"] + ) def test_sort_another_section_db(self) -> None: self.set_models( @@ -148,7 +151,10 @@ def test_sort_another_section_db(self) -> None: {"assignment_id": 222, "candidate_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Additional db_instances found." in response.json["message"] + assert ( + "assignment_candidate sorting failed, because some elements were not included in the call." + in response.json["message"] + ) def test_create_no_permissions(self) -> None: self.base_permission_test( diff --git a/tests/system/action/chat_group/test_sort.py b/tests/system/action/chat_group/test_sort.py index 5350e223b..51c98ed13 100644 --- a/tests/system/action/chat_group/test_sort.py +++ b/tests/system/action/chat_group/test_sort.py @@ -89,7 +89,10 @@ def test_sort_missing_model(self) -> None: {"meeting_id": 222, "chat_group_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Id 32 not in db_instances." in response.json["message"] + assert ( + "chat_group sorting failed, because element chat_group/32 doesn't exist." + in response.json["message"] + ) def test_sort_additional_chat_groups_in_meeting(self) -> None: self.set_models( @@ -118,7 +121,10 @@ def test_sort_additional_chat_groups_in_meeting(self) -> None: {"meeting_id": 222, "chat_group_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Additional db_instances found." in response.json["message"] + assert ( + "chat_group sorting failed, because some elements were not included in the call." + in response.json["message"] + ) def test_sort_no_permissions(self) -> None: self.base_permission_test( diff --git a/tests/system/action/motion_category/test_sort_motions_in_categories.py b/tests/system/action/motion_category/test_sort_motions_in_categories.py index 3dfe9ecf2..b3696c4c0 100644 --- a/tests/system/action/motion_category/test_sort_motions_in_categories.py +++ b/tests/system/action/motion_category/test_sort_motions_in_categories.py @@ -50,7 +50,10 @@ def test_sort_missing_model(self) -> None: {"id": 222, "motion_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Id 32 not in db_instances." in response.json["message"] + assert ( + "motion sorting failed, because element motion/32 doesn't exist." + in response.json["message"] + ) def test_sort_another_section_db(self) -> None: self.set_models( @@ -67,7 +70,10 @@ def test_sort_another_section_db(self) -> None: {"id": 222, "motion_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Additional db_instances found." in response.json["message"] + assert ( + "motion sorting failed, because some elements were not included in the call." + in response.json["message"] + ) def test_sort_no_permission(self) -> None: self.base_permission_test( diff --git a/tests/system/action/motion_comment_section/test_sort.py b/tests/system/action/motion_comment_section/test_sort.py index 1a60e2806..32dc535d2 100644 --- a/tests/system/action/motion_comment_section/test_sort.py +++ b/tests/system/action/motion_comment_section/test_sort.py @@ -63,7 +63,10 @@ def test_sort_missing_model(self) -> None: {"meeting_id": 222, "motion_comment_section_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Id 32 not in db_instances." in response.json["message"] + assert ( + "motion_comment_section sorting failed, because element motion_comment_section/32 doesn't exist." + in response.json["message"] + ) def test_sort_another_section_db(self) -> None: self.set_models( @@ -91,7 +94,10 @@ def test_sort_another_section_db(self) -> None: {"meeting_id": 222, "motion_comment_section_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Additional db_instances found." in response.json["message"] + assert ( + "motion_comment_section sorting failed, because some elements were not included in the call." + in response.json["message"] + ) def test_sort_no_permissions(self) -> None: self.base_permission_test( diff --git a/tests/system/action/motion_state/test_sort.py b/tests/system/action/motion_state/test_sort.py index f829a2d24..ef4f022d5 100644 --- a/tests/system/action/motion_state/test_sort.py +++ b/tests/system/action/motion_state/test_sort.py @@ -38,7 +38,10 @@ def test_sort_extra_id_in_payload(self) -> None: {"workflow_id": 1, "motion_state_ids": [3, 2, 4, 1]}, ) self.assert_status_code(response, 400) - assert "Id 4 not in db_instances." == response.json["message"] + assert ( + "motion_state sorting failed, because element motion_state/4 doesn't exist." + == response.json["message"] + ) def test_sort_missing_id_in_payload(self) -> None: self.set_models(self.permission_test_models) @@ -47,7 +50,10 @@ def test_sort_missing_id_in_payload(self) -> None: {"workflow_id": 1, "motion_state_ids": [3, 1]}, ) self.assert_status_code(response, 400) - assert "Additional db_instances found." == response.json["message"] + assert ( + "motion_state sorting failed, because some elements were not included in the call." + == response.json["message"] + ) def test_sort_no_permissions(self) -> None: self.base_permission_test( diff --git a/tests/system/action/motion_statute_paragraph/test_sort.py b/tests/system/action/motion_statute_paragraph/test_sort.py index 919aa9390..e0df7633b 100644 --- a/tests/system/action/motion_statute_paragraph/test_sort.py +++ b/tests/system/action/motion_statute_paragraph/test_sort.py @@ -63,7 +63,10 @@ def test_sort_missing_model(self) -> None: {"meeting_id": 222, "statute_paragraph_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Id 32 not in db_instances." in response.json["message"] + assert ( + "motion_statute_paragraph sorting failed, because element motion_statute_paragraph/32 doesn't exist." + in response.json["message"] + ) def test_sort_another_section_db(self) -> None: self.set_models( @@ -91,7 +94,10 @@ def test_sort_another_section_db(self) -> None: {"meeting_id": 222, "statute_paragraph_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Additional db_instances found." in response.json["message"] + assert ( + "motion_statute_paragraph sorting failed, because some elements were not included in the call." + in response.json["message"] + ) def test_sort_no_permissions(self) -> None: self.base_permission_test( diff --git a/tests/system/action/motion_submitter/test_sort.py b/tests/system/action/motion_submitter/test_sort.py index c2a78fb60..2c4cc0d81 100644 --- a/tests/system/action/motion_submitter/test_sort.py +++ b/tests/system/action/motion_submitter/test_sort.py @@ -45,7 +45,10 @@ def test_sort_missing_model(self) -> None: {"motion_id": 222, "motion_submitter_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Id 32 not in db_instances." in response.json["message"] + assert ( + "motion_submitter sorting failed, because element motion_submitter/32 doesn't exist." + in response.json["message"] + ) def test_sort_another_section_db(self) -> None: self.set_models( @@ -62,7 +65,10 @@ def test_sort_another_section_db(self) -> None: {"motion_id": 222, "motion_submitter_ids": [32, 31]}, ) self.assert_status_code(response, 400) - assert "Additional db_instances found." in response.json["message"] + assert ( + "motion_submitter sorting failed, because some elements were not included in the call." + in response.json["message"] + ) def test_sort_no_permissions(self) -> None: self.base_permission_test( diff --git a/tests/system/action/speaker/test_sort.py b/tests/system/action/speaker/test_sort.py index 221458f6e..776e0f0bd 100644 --- a/tests/system/action/speaker/test_sort.py +++ b/tests/system/action/speaker/test_sort.py @@ -43,7 +43,10 @@ def test_sort_missing_model(self) -> None: "speaker.sort", {"list_of_speakers_id": 222, "speaker_ids": [32, 31]} ) self.assert_status_code(response, 400) - assert "Id 32 not in db_instances." in response.json["message"] + assert ( + "speaker sorting failed, because element speaker/32 doesn't exist." + in response.json["message"] + ) def test_sort_another_section_db(self) -> None: self.set_models( @@ -59,7 +62,10 @@ def test_sort_another_section_db(self) -> None: "speaker.sort", {"list_of_speakers_id": 222, "speaker_ids": [32, 31]} ) self.assert_status_code(response, 400) - assert "Additional db_instances found." in response.json["message"] + assert ( + "speaker sorting failed, because some elements were not included in the call." + in response.json["message"] + ) def test_sort_no_permissions(self) -> None: self.base_permission_test(