Fixed deletion of agenda items.

Introduced by #4352
This commit is contained in:
FinnStutzenstein 2019-02-25 11:12:58 +01:00
parent fc2963f00a
commit 70d7f49afe
2 changed files with 30 additions and 1 deletions

View File

@ -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

View File

@ -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.