9f12763f8b
Server: - ListOfSpeakers (LOS) is now a speprate model, containing of an id, speakers, closed and a content_object. - Moved all speaker related views from ItemViewSet to the new ListOfSpeakersViewSet. - Make Mixins for content objects of items and lists of speakers. - Migrations: Move the lists of speakers from items to the LOS model. Client: - Removed the speaker repo and moved functionality to the new ListOfSpeakersRepositoryService. - Splitted base classes for agenda item content objects to items and LOS. - CurrentAgendaItemService -> CurrentListOfSpeakersSerivce - Cleaned up the list of speakers component.
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import pytest
|
|
from django.urls import reverse
|
|
from rest_framework import status
|
|
|
|
from openslides.agenda.models import Item
|
|
from openslides.topics.models import Topic
|
|
from openslides.utils.test import TestCase
|
|
|
|
from ..helpers import count_queries
|
|
|
|
|
|
@pytest.mark.django_db(transaction=False)
|
|
def test_topic_item_db_queries():
|
|
"""
|
|
Tests that only the following db queries are done:
|
|
* 1 requests to get the list of all topics,
|
|
* 1 request to get attachments,
|
|
* 1 request to get the agenda item
|
|
* 1 request to get the list of speakers
|
|
"""
|
|
for index in range(10):
|
|
Topic.objects.create(title=f"topic-{index}")
|
|
|
|
assert count_queries(Topic.get_elements) == 4
|
|
|
|
|
|
class TopicCreate(TestCase):
|
|
"""
|
|
Tests creation of new topics.
|
|
"""
|
|
|
|
def setUp(self):
|
|
self.client.login(username="admin", password="admin")
|
|
|
|
def test_simple_create(self):
|
|
response = self.client.post(
|
|
reverse("topic-list"),
|
|
{
|
|
"title": "test_title_ahyo1uifoo9Aiph2av5a",
|
|
"text": "test_text_chu9Uevoo5choo0Xithe",
|
|
},
|
|
)
|
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
|
topic = Topic.objects.get()
|
|
self.assertEqual(topic.title, "test_title_ahyo1uifoo9Aiph2av5a")
|
|
self.assertEqual(topic.text, "test_text_chu9Uevoo5choo0Xithe")
|
|
self.assertEqual(Item.objects.get(), topic.agenda_item)
|