Add new TestCase class in utils to call the signal on running every test.
This commit is contained in:
parent
9679be1867
commit
03fff46517
27
openslides/utils/test.py
Normal file
27
openslides/utils/test.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
openslides.utils.test
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Unit test class.
|
||||||
|
|
||||||
|
:copyright: 2011-2013 by OpenSlides team, see AUTHORS.
|
||||||
|
:license: GNU GPL, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
from django.test import TestCase as _TestCase
|
||||||
|
|
||||||
|
from openslides.core.signals import post_database_setup
|
||||||
|
|
||||||
|
|
||||||
|
class TestCase(_TestCase):
|
||||||
|
"""
|
||||||
|
Overwrites Django's TestCase class to call the post_database_setup
|
||||||
|
signal after the preparation of every test.
|
||||||
|
"""
|
||||||
|
def _pre_setup(self, *args, **kwargs):
|
||||||
|
return_value = super(TestCase, self)._pre_setup(*args, **kwargs)
|
||||||
|
post_database_setup.send(sender=self)
|
||||||
|
return return_value
|
@ -10,10 +10,10 @@
|
|||||||
:license: GNU GPL, see LICENSE for more details.
|
:license: GNU GPL, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.test import TestCase
|
|
||||||
from django.test.client import Client
|
from django.test.client import Client
|
||||||
from django.db.models.query import EmptyQuerySet
|
from django.db.models.query import EmptyQuerySet
|
||||||
|
|
||||||
|
from openslides.utils.test import TestCase
|
||||||
from openslides.projector.api import get_active_slide
|
from openslides.projector.api import get_active_slide
|
||||||
from openslides.participant.models import User
|
from openslides.participant.models import User
|
||||||
from openslides.agenda.models import Item
|
from openslides.agenda.models import Item
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
:license: GNU GPL, see LICENSE for more details.
|
:license: GNU GPL, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.test import TestCase
|
from openslides.utils.test import TestCase
|
||||||
|
|
||||||
from openslides.core.signals import post_database_setup
|
|
||||||
from openslides.participant.models import User
|
from openslides.participant.models import User
|
||||||
from openslides.config.models import config
|
from openslides.config.models import config
|
||||||
from openslides.motion.models import Motion, Workflow, State
|
from openslides.motion.models import Motion, Workflow, State
|
||||||
@ -19,7 +17,6 @@ from openslides.motion.exceptions import WorkflowError
|
|||||||
|
|
||||||
class ModelTest(TestCase):
|
class ModelTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
post_database_setup.send(sender=self)
|
|
||||||
self.motion = Motion.objects.create(title='v1')
|
self.motion = Motion.objects.create(title='v1')
|
||||||
self.test_user = User.objects.create(username='blub')
|
self.test_user = User.objects.create(username='blub')
|
||||||
self.workflow = Workflow.objects.get(pk=1)
|
self.workflow = Workflow.objects.get(pk=1)
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
:license: GNU GPL, see LICENSE for more details.
|
:license: GNU GPL, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.test import TestCase
|
from openslides.utils.test import TestCase
|
||||||
|
|
||||||
from openslides.utils.person import get_person, Persons
|
from openslides.utils.person import get_person, Persons
|
||||||
from openslides.participant.api import gen_username, gen_password
|
from openslides.participant.api import gen_username, gen_password
|
||||||
from openslides.participant.models import User, Group
|
from openslides.participant.models import User, Group
|
||||||
|
Loading…
Reference in New Issue
Block a user