OpenSlides/tests/old/utils/test_widgets.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

50 lines
1.5 KiB
Python

from django.contrib.auth.models import AnonymousUser
from django.test.client import RequestFactory
from openslides.utils.test import TestCase
from openslides.utils.widgets import Widget
class WidgetObject(TestCase):
request_factory = RequestFactory()
def get_widget(self, name):
request = self.request_factory.get('/')
request.user = AnonymousUser()
for widget in Widget.get_all(request):
if widget.name == name:
value = widget
break
else:
value = False
return value
def test_connecting_signal(self):
class TestWidgetOne(Widget):
name = 'test_case_widget_begae7poh1Ahshohfi1r'
self.assertTrue(self.get_widget('test_case_widget_begae7poh1Ahshohfi1r'))
def test_not_connecting_signal(self):
class TestWidgetTwo(Widget):
name = 'test_case_widget_zuRietaewiCii9mahDah'
@classmethod
def get_dispatch_uid(cls):
return None
self.assertFalse(self.get_widget('test_case_widget_zuRietaewiCii9mahDah'))
def test_missing_template(self):
class TestWidgetThree(Widget):
name = 'test_widget_raiLaiPhahQuahngeer4'
widget = self.get_widget('test_widget_raiLaiPhahQuahngeer4')
self.assertRaisesMessage(
NotImplementedError,
'A widget class must define either a get_html method or have template_name argument.',
widget.get_html)