Added more tests for the agenda
This commit is contained in:
parent
fddf929ab5
commit
abd21dd345
@ -49,6 +49,8 @@ class SlideMixin(object):
|
||||
"""
|
||||
Return True, if the the slide is the active slide.
|
||||
"""
|
||||
if self.id is None:
|
||||
return False
|
||||
from openslides.projector.api import get_active_slide
|
||||
return get_active_slide(only_sid=True) == self.sid
|
||||
|
||||
|
0
tests/agenda/__init__.py
Normal file
0
tests/agenda/__init__.py
Normal file
18
tests/agenda/models.py
Normal file
18
tests/agenda/models.py
Normal file
@ -0,0 +1,18 @@
|
||||
from django.db import models
|
||||
|
||||
from openslides.projector.projector import SlideMixin
|
||||
from openslides.projector.api import register_slidemodel
|
||||
|
||||
|
||||
class ReleatedItem(SlideMixin, models.Model):
|
||||
prefix = 'releateditem'
|
||||
|
||||
name = models.CharField(max_length='255')
|
||||
|
||||
def get_agenda_title(self):
|
||||
return self.name
|
||||
|
||||
def get_agenda_title_supplement(self):
|
||||
return 'test item'
|
||||
|
||||
register_slidemodel(ReleatedItem)
|
@ -19,6 +19,8 @@ from openslides.participant.models import User
|
||||
from openslides.agenda.models import Item
|
||||
from openslides.agenda.slides import agenda_show
|
||||
|
||||
from .models import ReleatedItem
|
||||
|
||||
|
||||
class ItemTest(TestCase):
|
||||
def setUp(self):
|
||||
@ -26,6 +28,8 @@ class ItemTest(TestCase):
|
||||
self.item2 = Item.objects.create(title='item2')
|
||||
self.item3 = Item.objects.create(title='item1A', parent=self.item1)
|
||||
self.item4 = Item.objects.create(title='item1Aa', parent=self.item3)
|
||||
self.releated = ReleatedItem.objects.create(name='foo')
|
||||
self.item5 = Item.objects.create(title='item5', related_sid=self.releated.sid)
|
||||
|
||||
def testClosed(self):
|
||||
self.assertFalse(self.item1.closed)
|
||||
@ -47,11 +51,6 @@ class ItemTest(TestCase):
|
||||
self.assertTrue(self.item3 in self.item1.get_children())
|
||||
self.assertFalse(self.item4 in self.item1.get_children())
|
||||
|
||||
l = Item.objects.all()
|
||||
self.assertEqual(
|
||||
str(l),
|
||||
"[<Item: item1>, <Item: item1A>, <Item: item1Aa>, <Item: item2>]")
|
||||
|
||||
def testForms(self):
|
||||
for item in Item.objects.all():
|
||||
initial = item.weight_form.initial
|
||||
@ -89,6 +88,13 @@ class ItemTest(TestCase):
|
||||
self.assertEqual(data['template'], 'projector/AgendaSummary.html')
|
||||
self.assertEqual(data['title'], 'Agenda')
|
||||
|
||||
def test_releated_item(self):
|
||||
self.assertEqual(self.item5.get_title(), self.releated.name)
|
||||
self.assertEqual(self.item5.get_title_supplement(), 'test item')
|
||||
self.assertEqual(self.item5.get_related_type(), 'releateditem')
|
||||
self.assertEqual(self.item5.print_related_type(), 'Releateditem')
|
||||
|
||||
|
||||
|
||||
class ViewTest(TestCase):
|
||||
def setUp(self):
|
Loading…
Reference in New Issue
Block a user