diff --git a/tests/system/action/topic/test_create.py b/tests/system/action/topic/test_create.py index d0d6d455b..3b91e09e9 100644 --- a/tests/system/action/topic/test_create.py +++ b/tests/system/action/topic/test_create.py @@ -167,6 +167,71 @@ def test_create_multiple_with_existing_sequential_number(self) -> None: topic = self.get_model("topic/3") self.assertEqual(topic.get("sequential_number"), 44) + def test_create_meeting_id_agenda_tag_ids_mismatch(self) -> None: + """Tag 8 is from meeting 8 and a topic for meeting 1 should be created. + This should lead to an error.""" + self.set_models( + { + "meeting/1": {"is_active_in_organization_id": 1}, + "meeting/8": { + "is_active_in_organization_id": 1, + "tag_ids": [8], + }, + "tag/8": {"name": "tag8", "meeting_id": 8}, + } + ) + response = self.request( + "topic.create", + { + "meeting_id": 1, + "title": "A", + "agenda_type": AgendaItem.INTERNAL_ITEM, + "agenda_duration": 60, + "agenda_tag_ids": [8], + }, + ) + self.assert_status_code(response, 400) + assert ( + "The following models do not belong to meeting 1: ['tag/8']" + in response.json["message"] + ) + + def test_create_with_agenda_tag_ids(self) -> None: + """Tag 1 is from meeting 1 and a topic for meeting 1 should be created.""" + self.set_models( + { + "meeting/1": {"is_active_in_organization_id": 1, "tag_ids": [1]}, + "tag/1": {"name": "test tag", "meeting_id": 1}, + } + ) + response = self.request( + "topic.create", + { + "meeting_id": 1, + "title": "A", + "agenda_type": AgendaItem.INTERNAL_ITEM, + "agenda_duration": 60, + "agenda_tag_ids": [1], + }, + ) + self.assert_status_code(response, 200) + self.assert_model_exists( + "topic/1", {"meeting_id": 1, "title": "A", "agenda_item_id": 1} + ) + self.assert_model_exists( + "agenda_item/1", + { + "meeting_id": 1, + "type": AgendaItem.INTERNAL_ITEM, + "duration": 60, + "tag_ids": [1], + }, + ) + self.assert_model_exists( + "tag/1", + {"meeting_id": 1, "name": "test tag", "tagged_ids": ["agenda_item/1"]}, + ) + def test_create_no_permission(self) -> None: self.base_permission_test( {}, "topic.create", {"meeting_id": 1, "title": "test"}