Added more tests for the agenda

This commit is contained in:
Oskar Hahn 2012-11-26 10:05:51 +01:00
parent fddf929ab5
commit abd21dd345
4 changed files with 31 additions and 5 deletions

View File

@ -49,6 +49,8 @@ class SlideMixin(object):
""" """
Return True, if the the slide is the active slide. 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 from openslides.projector.api import get_active_slide
return get_active_slide(only_sid=True) == self.sid return get_active_slide(only_sid=True) == self.sid

0
tests/agenda/__init__.py Normal file
View File

18
tests/agenda/models.py Normal file
View 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)

View File

@ -19,6 +19,8 @@ from openslides.participant.models import User
from openslides.agenda.models import Item from openslides.agenda.models import Item
from openslides.agenda.slides import agenda_show from openslides.agenda.slides import agenda_show
from .models import ReleatedItem
class ItemTest(TestCase): class ItemTest(TestCase):
def setUp(self): def setUp(self):
@ -26,6 +28,8 @@ class ItemTest(TestCase):
self.item2 = Item.objects.create(title='item2') self.item2 = Item.objects.create(title='item2')
self.item3 = Item.objects.create(title='item1A', parent=self.item1) self.item3 = Item.objects.create(title='item1A', parent=self.item1)
self.item4 = Item.objects.create(title='item1Aa', parent=self.item3) 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): def testClosed(self):
self.assertFalse(self.item1.closed) self.assertFalse(self.item1.closed)
@ -47,11 +51,6 @@ class ItemTest(TestCase):
self.assertTrue(self.item3 in self.item1.get_children()) self.assertTrue(self.item3 in self.item1.get_children())
self.assertFalse(self.item4 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): def testForms(self):
for item in Item.objects.all(): for item in Item.objects.all():
initial = item.weight_form.initial initial = item.weight_form.initial
@ -89,6 +88,13 @@ class ItemTest(TestCase):
self.assertEqual(data['template'], 'projector/AgendaSummary.html') self.assertEqual(data['template'], 'projector/AgendaSummary.html')
self.assertEqual(data['title'], 'Agenda') 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): class ViewTest(TestCase):
def setUp(self): def setUp(self):