OpenSlides/server/tests/unit/agenda/test_models.py

25 lines
841 B
Python
Raw Normal View History

from unittest import TestCase
from unittest.mock import patch
from openslides.agenda.models import Item
class TestItemTitle(TestCase):
2019-01-06 16:22:33 +01:00
@patch("openslides.agenda.models.Item.content_object")
def test_title_from_content_object(self, content_object):
item = Item()
2019-02-15 12:17:08 +01:00
content_object.get_agenda_title_information.return_value = {
"attr": "related_title"
}
2019-02-15 12:17:08 +01:00
self.assertEqual(item.title_information, {"attr": "related_title"})
2019-01-06 16:22:33 +01:00
@patch("openslides.agenda.models.Item.content_object")
def test_title_invalid_related(self, content_object):
item = Item()
2019-02-15 12:17:08 +01:00
content_object.get_agenda_title_information.return_value = "related_title"
del content_object.get_agenda_title_information
with self.assertRaises(NotImplementedError):
2019-02-15 12:17:08 +01:00
item.title_information