From 6a89f9817a55a5fe9d0a7fd565cda681ecab1a1e Mon Sep 17 00:00:00 2001 From: "openslides-automation[bot]" <125256978+openslides-automation[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:06:44 +0200 Subject: [PATCH] Raise proper error for `meeting_id === null` in mediafile.update (#2620) (#2621) --- openslides_backend/action/actions/mediafile/update.py | 4 ++-- tests/system/action/mediafile/test_update.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/openslides_backend/action/actions/mediafile/update.py b/openslides_backend/action/actions/mediafile/update.py index ae30794f4..3f8f4862c 100644 --- a/openslides_backend/action/actions/mediafile/update.py +++ b/openslides_backend/action/actions/mediafile/update.py @@ -4,7 +4,7 @@ from ....permissions.permissions import Permissions from ....shared.exceptions import ActionException from ....shared.patterns import fqid_from_collection_and_id -from ....shared.schema import optional_id_schema +from ....shared.schema import required_id_schema from ...generics.update import UpdateAction from ...mixins.meeting_mediafile_helper import find_meeting_mediafile from ...util.default_schema import DefaultSchema @@ -29,7 +29,7 @@ class MediafileUpdate(MediafileMixin, UpdateAction, MediafileCalculatedFieldsMix schema = DefaultSchema(Mediafile()).get_update_schema( optional_properties=["title", "token"], additional_optional_fields={ - "meeting_id": optional_id_schema, + "meeting_id": required_id_schema, "access_group_ids": MeetingMediafile.access_group_ids.get_schema(), }, ) diff --git a/tests/system/action/mediafile/test_update.py b/tests/system/action/mediafile/test_update.py index a9142ee0b..469d9fc86 100644 --- a/tests/system/action/mediafile/test_update.py +++ b/tests/system/action/mediafile/test_update.py @@ -909,6 +909,14 @@ def test_update_filename_error(self) -> None: "data must not contain {'filename'} properties", response.json["message"] ) + def test_update_title_with_orga_owner_meeting_id_none(self) -> None: + self.set_models(self.orga_permission_test_models) + response = self.request( + "mediafile.update", {"id": 111, "title": "blob.txt", "meeting_id": None} + ) + self.assert_status_code(response, 400) + self.assertIn("data.meeting_id must be integer", response.json["message"]) + def test_update_access_group_with_orga_owner(self) -> None: self.set_models(self.orga_permission_test_models) response = self.request(