OpenSlides/tests/test_motion.py

42 lines
1.2 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
2012-10-24 11:04:23 +02:00
openslides.motion.tests
2012-04-25 22:29:19 +02:00
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2012-10-24 11:04:23 +02:00
Unit tests for the motion app.
2012-04-25 22:29:19 +02:00
:copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
from django.test import TestCase
from openslides.participant.models import User
from openslides.motion.models import Motion
2012-10-24 11:04:23 +02:00
class MotionTest(TestCase):
def setUp(self):
self.admin = User(username='testadmin')
self.admin.save()
self.anonym = User(username='testanoym')
self.anonym.save()
2012-10-24 11:04:23 +02:00
self.app1 = Motion(submitter=self.admin)
self.app1.save()
def refresh(self):
2012-10-24 11:04:23 +02:00
self.app1 = Motion.objects.get(pk=self.app1.id)
def testVersion(self):
self.assertTrue(self.app1.versions.exists())
self.assertEqual(self.app1.last_version, self.app1.versions[0])
self.assertEqual(self.app1.creation_time, self.app1.last_version.time)
self.app1.title = "app1"
self.app1.save()
self.refresh()
self.assertEqual(self.app1.versions.count(), 2)
self.assertEqual(self.app1.last_version, self.app1.versions[1])