2015-03-09 15:40:54 +01:00
|
|
|
from unittest import skip
|
|
|
|
|
2013-04-02 17:40:57 +02:00
|
|
|
from django.test.client import Client
|
|
|
|
|
|
|
|
from openslides.config.api import config
|
2014-10-11 14:34:49 +02:00
|
|
|
from openslides.users.models import User
|
2013-09-25 10:01:01 +02:00
|
|
|
from openslides.utils.test import TestCase
|
2013-04-02 17:40:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
class PersonalInfoWidget(TestCase):
|
|
|
|
"""
|
|
|
|
Tests the content of the personal info widget.
|
|
|
|
"""
|
2013-05-12 01:46:40 +02:00
|
|
|
def import_agenda(self):
|
|
|
|
"""
|
|
|
|
Helper function to make the module agenda optional.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
from openslides import agenda
|
|
|
|
except ImportError:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return agenda
|
|
|
|
|
2013-04-02 17:40:57 +02:00
|
|
|
def import_motion(self):
|
|
|
|
"""
|
|
|
|
Helper function to make the module motion optional.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
from openslides import motion
|
|
|
|
except ImportError:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return motion
|
|
|
|
|
|
|
|
def import_assignment(self):
|
|
|
|
"""
|
|
|
|
Helper function to make the module assignment optional.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
from openslides import assignment
|
|
|
|
except ImportError:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return assignment
|
|
|
|
|
|
|
|
def setUp(self):
|
2014-10-11 14:34:49 +02:00
|
|
|
self.user = User.objects.create_user('HansMeiser', 'default')
|
2013-04-02 17:40:57 +02:00
|
|
|
self.client = Client()
|
|
|
|
self.client.login(username='HansMeiser', password='default')
|
|
|
|
|
|
|
|
def test_widget_appearance(self):
|
2013-12-09 23:56:01 +01:00
|
|
|
response = self.client.get('/dashboard/')
|
2013-12-03 01:50:10 +01:00
|
|
|
self.assertContains(response, 'My personal info', status_code=200)
|
2013-05-12 01:46:40 +02:00
|
|
|
|
2015-03-09 15:40:54 +01:00
|
|
|
@skip
|
2013-05-12 01:46:40 +02:00
|
|
|
def test_item_list(self):
|
|
|
|
agenda = self.import_agenda()
|
|
|
|
if agenda:
|
|
|
|
item_1 = agenda.models.Item.objects.create(title='My Item Title iw5ohNgee4eiYahb5Eiv')
|
2014-10-11 14:34:49 +02:00
|
|
|
speaker = agenda.models.Speaker.objects.add(item=item_1, user=self.user)
|
2013-12-09 23:56:01 +01:00
|
|
|
response = self.client.get('/dashboard/')
|
2013-05-12 01:46:40 +02:00
|
|
|
self.assertContains(response, 'I am on the list of speakers of the following items:', status_code=200)
|
|
|
|
self.assertContains(response, 'My Item Title iw5ohNgee4eiYahb5Eiv', status_code=200)
|
|
|
|
speaker.begin_speach()
|
2013-12-09 23:56:01 +01:00
|
|
|
response = self.client.get('/dashboard/')
|
2013-05-12 01:46:40 +02:00
|
|
|
self.assertNotContains(response, 'My Item Title iw5ohNgee4eiYahb5Eiv', status_code=200)
|
2013-04-02 17:40:57 +02:00
|
|
|
|
|
|
|
def test_submitter_list(self):
|
|
|
|
motion = self.import_motion()
|
|
|
|
if motion:
|
|
|
|
motion_1 = motion.models.Motion.objects.create(title='My Motion Title pa8aeNohYai0ahge', text='My Motion Text')
|
2013-05-31 14:00:24 +02:00
|
|
|
motion_2 = motion.models.Motion.objects.create(title='My Motion Title quielohL7vah1weochai', text='My Motion Text')
|
2013-09-25 10:01:01 +02:00
|
|
|
motion.models.MotionSubmitter.objects.create(motion=motion_1, person=self.user)
|
|
|
|
motion.models.MotionSubmitter.objects.create(motion=motion_2, person=self.user)
|
2013-12-09 23:56:01 +01:00
|
|
|
response = self.client.get('/dashboard/')
|
2013-04-02 17:40:57 +02:00
|
|
|
self.assertContains(response, 'I submitted the following motions:', status_code=200)
|
|
|
|
self.assertContains(response, 'My Motion Title pa8aeNohYai0ahge', status_code=200)
|
2013-05-31 14:00:24 +02:00
|
|
|
self.assertContains(response, 'My Motion Title quielohL7vah1weochai', status_code=200)
|
2013-04-02 17:40:57 +02:00
|
|
|
|
|
|
|
def test_supporter_list(self):
|
|
|
|
motion = self.import_motion()
|
|
|
|
if motion:
|
2013-05-31 14:00:24 +02:00
|
|
|
motion_1 = motion.models.Motion.objects.create(title='My Motion Title jahN9phaiThae5ooKubu', text='My Motion Text')
|
|
|
|
motion_2 = motion.models.Motion.objects.create(title='My Motion Title vech9ash8aeh9eej2Ga2', text='My Motion Text')
|
2013-09-25 10:01:01 +02:00
|
|
|
motion.models.MotionSupporter.objects.create(motion=motion_1, person=self.user)
|
|
|
|
motion.models.MotionSupporter.objects.create(motion=motion_2, person=self.user)
|
2013-04-02 17:40:57 +02:00
|
|
|
config['motion_min_supporters'] = 1
|
2013-12-09 23:56:01 +01:00
|
|
|
response = self.client.get('/dashboard/')
|
2013-04-02 17:40:57 +02:00
|
|
|
self.assertContains(response, 'I support the following motions:', status_code=200)
|
2013-05-31 14:00:24 +02:00
|
|
|
self.assertContains(response, 'My Motion Title jahN9phaiThae5ooKubu', status_code=200)
|
|
|
|
self.assertContains(response, 'My Motion Title vech9ash8aeh9eej2Ga2', status_code=200)
|
2013-04-02 17:40:57 +02:00
|
|
|
|
|
|
|
def test_candidate_list(self):
|
|
|
|
assignment = self.import_assignment()
|
|
|
|
if assignment:
|
2015-01-25 15:10:34 +01:00
|
|
|
assignment_1 = assignment.models.Assignment.objects.create(title='Hausmeister ooKoh7roApoo3phe', open_posts=1)
|
|
|
|
assignment_1.set_candidate(self.user)
|
2013-12-09 23:56:01 +01:00
|
|
|
response = self.client.get('/dashboard/')
|
2013-04-02 17:40:57 +02:00
|
|
|
self.assertContains(response, 'I am candidate for the following elections:', status_code=200)
|
|
|
|
self.assertContains(response, 'Hausmeister ooKoh7roApoo3phe', status_code=200)
|