From 70d7f49afe605e4d82fe7e5811616ebde33d17f2 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Mon, 25 Feb 2019 11:12:58 +0100 Subject: [PATCH] Fixed deletion of agenda items. Introduced by #4352 --- openslides/agenda/signals.py | 2 +- tests/integration/agenda/test_viewset.py | 29 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/openslides/agenda/signals.py b/openslides/agenda/signals.py index e18c4475d..a772b0dd8 100644 --- a/openslides/agenda/signals.py +++ b/openslides/agenda/signals.py @@ -37,7 +37,7 @@ def listen_to_related_object_post_delete(sender, instance, **kwargs): Receiver function to delete agenda items. It is connected to the signal django.db.models.signals.post_delete during app loading. """ - if hasattr(instance, "get_agenda_title"): + if hasattr(instance, "get_agenda_title_information"): content_type = ContentType.objects.get_for_model(instance) try: # Attention: This delete() call is also necessary to remove diff --git a/tests/integration/agenda/test_viewset.py b/tests/integration/agenda/test_viewset.py index ee44730a6..fd7f3a98b 100644 --- a/tests/integration/agenda/test_viewset.py +++ b/tests/integration/agenda/test_viewset.py @@ -18,6 +18,35 @@ from openslides.utils.test import TestCase from ..helpers import count_queries +class ContentObjects(TestCase): + """ + Tests content objects with Topic as a content object. + Asserts, that it is recognizes as a content object and tests creation + and deletion of it and the related agenda item. + """ + + def setUp(self): + self.client = APIClient() + self.client.login(username="admin", password="admin") + + def test_topic_is_content_object(self): + assert hasattr(Topic(), "get_agenda_title_information") + + def test_create_content_object(self): + topic = Topic.objects.create(title="test_title_fk3Oc209JDiunw2!wwoH") + + assert topic.agenda_item is not None + response = self.client.get(reverse("item-detail", args=[topic.agenda_item.pk])) + self.assertEqual(response.status_code, status.HTTP_200_OK) + + def test_delete_content_object(self): + topic = Topic.objects.create(title="test_title_lwOCK32jZGFb37DpmoP(") + item_id = topic.agenda_item.id + topic.delete() + response = self.client.get(reverse("item-detail", args=[item_id])) + self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + + class RetrieveItem(TestCase): """ Tests retrieving items.