2015-02-06 23:57:52 +01:00
|
|
|
from unittest import TestCase
|
2015-06-16 10:37:23 +02:00
|
|
|
from unittest.mock import patch
|
2015-02-06 23:57:52 +01:00
|
|
|
|
|
|
|
from openslides.agenda.models import Item
|
|
|
|
|
|
|
|
|
2015-10-24 19:02:43 +02:00
|
|
|
class TestItemTitle(TestCase):
|
2015-02-06 23:57:52 +01:00
|
|
|
@patch('openslides.agenda.models.Item.content_object')
|
2015-10-24 19:02:43 +02:00
|
|
|
def test_title_from_content_object(self, content_object):
|
|
|
|
item = Item()
|
2015-02-06 23:57:52 +01:00
|
|
|
content_object.get_agenda_title.return_value = 'related_title'
|
|
|
|
|
|
|
|
self.assertEqual(
|
2015-10-24 19:02:43 +02:00
|
|
|
item.title,
|
2015-02-06 23:57:52 +01:00
|
|
|
'related_title')
|
|
|
|
|
2015-10-24 19:02:43 +02:00
|
|
|
@patch('openslides.agenda.models.Item.item_no', '5')
|
2015-02-06 23:57:52 +01:00
|
|
|
@patch('openslides.agenda.models.Item.content_object')
|
2015-10-24 19:02:43 +02:00
|
|
|
def test_title_with_item_no(self, content_object):
|
2015-02-06 23:57:52 +01:00
|
|
|
item = Item()
|
2015-10-24 19:02:43 +02:00
|
|
|
content_object.get_agenda_title.return_value = 'related_title'
|
2015-02-06 23:57:52 +01:00
|
|
|
|
|
|
|
self.assertEqual(
|
2015-10-24 19:02:43 +02:00
|
|
|
item.title,
|
|
|
|
'5 related_title')
|
2015-02-06 23:57:52 +01:00
|
|
|
|
|
|
|
@patch('openslides.agenda.models.Item.content_object')
|
2015-10-24 19:02:43 +02:00
|
|
|
def test_title_invalid_related(self, content_object):
|
2015-02-06 23:57:52 +01:00
|
|
|
item = Item()
|
2015-10-24 19:02:43 +02:00
|
|
|
content_object.get_agenda_title.return_value = 'related_title'
|
|
|
|
del content_object.get_agenda_title
|
2015-02-06 23:57:52 +01:00
|
|
|
|
|
|
|
with self.assertRaises(NotImplementedError):
|
2015-10-24 19:02:43 +02:00
|
|
|
item.title
|