Merge pull request #58 from ostcar/master

test pep8
This commit is contained in:
Oskar Hahn 2012-11-26 02:33:34 -08:00
commit 62a290c300
7 changed files with 110 additions and 80 deletions

View File

@ -5,6 +5,8 @@ python:
- "2.7"
install:
- pip install -r requirements.txt --use-mirrors
- pip install coverage django-discover-runner
- pip install coverage django-discover-runner pep8
- python extras/scripts/create_local_settings.py
script: coverage run ./manage.py test tests && coverage report -m
script:
- coverage run ./manage.py test tests && coverage report -m
- pep8 --max-line-length=150 --exclude="urls.py,motion/" --statistics openslides

View File

@ -138,7 +138,9 @@ class Group(DjangoGroup, PersonMixin, Person, SlideMixin):
person_prefix = 'group'
django_group = models.OneToOneField(DjangoGroup, editable=False, parent_link=True)
group_as_person = models.BooleanField(default=False, verbose_name=_("Use this group as participant"), help_text=_('For example as submitter of a motion.'))
group_as_person = models.BooleanField(
default=False, verbose_name=_("Use this group as participant"),
help_text=_('For example as submitter of a motion.'))
description = models.TextField(blank=True, verbose_name=_("Description"))
@models.permalink

View File

@ -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

View File

@ -116,93 +116,93 @@ stylesheet.add(ParagraphStyle(
name='Tablecell',
parent=stylesheet['Normal'],
fontSize=9))
stylesheet.add(ParagraphStyle(name = 'Signaturefield',
parent = stylesheet['Normal'],
spaceBefore = 15)
stylesheet.add(ParagraphStyle(name='Signaturefield',
parent=stylesheet['Normal'],
spaceBefore=15)
)
# Ballot stylesheets
stylesheet.add(ParagraphStyle(name = 'Ballot_title',
parent = stylesheet['Bold'],
fontSize = 12,
leading = 14,
leftIndent = 30),
stylesheet.add(ParagraphStyle(name='Ballot_title',
parent=stylesheet['Bold'],
fontSize=12,
leading=14,
leftIndent=30),
)
stylesheet.add(ParagraphStyle(name = 'Ballot_subtitle',
parent = stylesheet['Normal'],
fontSize = 10,
leading = 12,
leftIndent = 30,
rightIndent = 20,
spaceAfter = 5),
stylesheet.add(ParagraphStyle(name='Ballot_subtitle',
parent=stylesheet['Normal'],
fontSize=10,
leading=12,
leftIndent=30,
rightIndent=20,
spaceAfter=5),
)
stylesheet.add(ParagraphStyle(name = 'Ballot_description',
parent = stylesheet['Normal'],
fontSize = 7,
leading = 10,
leftIndent = 30),
stylesheet.add(ParagraphStyle(name='Ballot_description',
parent=stylesheet['Normal'],
fontSize=7,
leading=10,
leftIndent=30),
)
stylesheet.add(ParagraphStyle(name = 'Ballot_option',
parent = stylesheet['Normal'],
fontSize = 12,
leading = 24,
leftIndent = 30),
stylesheet.add(ParagraphStyle(name='Ballot_option',
parent=stylesheet['Normal'],
fontSize=12,
leading=24,
leftIndent=30),
)
stylesheet.add(ParagraphStyle(name = 'Monotype',
parent = stylesheet['Normal'],
fontName = 'Courier',
fontSize = 12,
leading = 24,
leftIndent = 30),
stylesheet.add(ParagraphStyle(name='Monotype',
parent=stylesheet['Normal'],
fontName='Courier',
fontSize=12,
leading=24,
leftIndent=30),
)
stylesheet.add(ParagraphStyle(name = 'Ballot_option_name',
parent = stylesheet['Normal'],
fontSize = 12,
leading = 15,
leftIndent = 30),
stylesheet.add(ParagraphStyle(name='Ballot_option_name',
parent=stylesheet['Normal'],
fontSize=12,
leading=15,
leftIndent=30),
)
stylesheet.add(ParagraphStyle(name = 'Ballot_option_group',
parent = stylesheet['Normal'],
fontSize = 8,
leading = 15,
leftIndent = 30),
stylesheet.add(ParagraphStyle(name='Ballot_option_group',
parent=stylesheet['Normal'],
fontSize=8,
leading=15,
leftIndent=30),
)
stylesheet.add(ParagraphStyle(name = 'Ballot_option_YNA',
parent = stylesheet['Normal'],
fontSize = 12,
leading = 15,
leftIndent = 49,
spaceAfter = 18),
stylesheet.add(ParagraphStyle(name='Ballot_option_YNA',
parent=stylesheet['Normal'],
fontSize=12,
leading=15,
leftIndent=49,
spaceAfter=18),
)
stylesheet.add(ParagraphStyle(name = 'Ballot_option_group_right',
parent = stylesheet['Normal'],
fontSize = 8,
leading = 16,
leftIndent = 49),
stylesheet.add(ParagraphStyle(name='Ballot_option_group_right',
parent=stylesheet['Normal'],
fontSize=8,
leading=16,
leftIndent=49),
)
stylesheet.add(ParagraphStyle(name = 'Badge_title',
parent = stylesheet['Bold'],
fontSize = 16,
leading = 22,
leftIndent = 30),
stylesheet.add(ParagraphStyle(name='Badge_title',
parent=stylesheet['Bold'],
fontSize=16,
leading=22,
leftIndent=30),
)
stylesheet.add(ParagraphStyle(name = 'Badge_subtitle',
parent = stylesheet['Normal'],
fontSize = 12,
leading = 24,
leftIndent = 30),
stylesheet.add(ParagraphStyle(name='Badge_subtitle',
parent=stylesheet['Normal'],
fontSize=12,
leading=24,
leftIndent=30),
)
stylesheet.add(ParagraphStyle(
name = 'Badge_italic',
parent = stylesheet['Italic'],
fontSize = 12,
leading = 24,
leftIndent = 30,
name='Badge_italic',
parent=stylesheet['Italic'],
fontSize=12,
leading=24,
leftIndent=30,
))
stylesheet.add(ParagraphStyle(
name = 'Badge_qrcode',
fontSize = 12,
leftIndent = 190,
name='Badge_qrcode',
fontSize=12,
leftIndent=190,
))

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.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):