OpenSlides/tests/utils/test_personal_info.py
2013-12-09 12:16:16 +01:00

32 lines
1008 B
Python

# -*- coding: utf-8 -*-
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)