OpenSlides/tests/old/utils/test_personal_info.py
Oskar Hahn e7230b7391 New Test order.
* seperate unittests and integration tests
* moved old tests in seperat folder 'old'
* created a testrunner that does not create a testdatabase, if only unittests are run
* wrote some unit- and integration tests as examples
* fixed user.get_short_name() to use the sort order from config
* fixed wrong url_pattern in the user app
2015-01-24 18:00:03 +01:00

30 lines
983 B
Python

from django.contrib.auth.models import AnonymousUser
from django.test.client import RequestFactory
from openslides.utils.test import TestCase
from openslides.utils.personal_info import PersonalInfo
class PersonalInfoObject(TestCase):
def get_infoblock(self, name):
request = RequestFactory().get('/')
request.user = AnonymousUser()
for infoblock in PersonalInfo.get_all(request):
if type(infoblock).__name__ == name:
value = infoblock
break
else:
value = False
return value
def test_get_queryset(self):
class TestInfoBlock_cu1Beir1zie5yeitie4e(PersonalInfo):
pass
infoblock = self.get_infoblock('TestInfoBlock_cu1Beir1zie5yeitie4e')
self.assertRaisesMessage(
NotImplementedError,
'Your class %s has to define a get_queryset method.' % repr(TestInfoBlock_cu1Beir1zie5yeitie4e),
infoblock.get_queryset)