This commit is contained in:
Matthias 2021-09-28 01:16:10 +02:00
parent 9d1d8bbeaa
commit 7040eda11e
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -4,8 +4,7 @@ from django.test import TestCase
from django.conf import settings from django.conf import settings
from django.conf.urls import url, include from django.conf.urls import url, include
from plugins.integration import IntegrationPlugin, MixinBase, SettingsMixin, UrlsMixin, NavigationMixin from plugins.integration import IntegrationPlugin, SettingsMixin, UrlsMixin, NavigationMixin # MixinBase
import part.templatetags.plugin_extras as plugin_tags
class BaseMixinDefinition: class BaseMixinDefinition:
@ -26,9 +25,9 @@ class SettingsMixinTest(BaseMixinDefinition, TestCase):
TEST_SETTINGS = {'setting1': [1, 2, 3]} TEST_SETTINGS = {'setting1': [1, 2, 3]}
def setUp(self): def setUp(self):
class cls(SettingsMixin, IntegrationPlugin): class SettingsCls(SettingsMixin, IntegrationPlugin):
SETTINGS = self.TEST_SETTINGS SETTINGS = self.TEST_SETTINGS
self.mixin = cls() self.mixin = SettingsCls()
def test_function(self): def test_function(self):
# settings variable # settings variable
@ -44,11 +43,11 @@ class UrlsMixinTest(BaseMixinDefinition, TestCase):
MIXIN_ENABLE_CHECK = 'has_urls' MIXIN_ENABLE_CHECK = 'has_urls'
def setUp(self): def setUp(self):
class cls(UrlsMixin, IntegrationPlugin): class UrlsCls(UrlsMixin, IntegrationPlugin):
def test(self): def test(self):
return 'ccc' return 'ccc'
URLS = [url('test', test, name='test'), ] URLS = [url('test', test, name='test'), ]
self.mixin = cls() self.mixin = UrlsCls()
def test_function(self): def test_function(self):
plg_name = self.mixin.plugin_name() plg_name = self.mixin.plugin_name()
@ -68,17 +67,17 @@ class NavigationMixinTest(BaseMixinDefinition, TestCase):
MIXIN_ENABLE_CHECK = 'has_naviation' MIXIN_ENABLE_CHECK = 'has_naviation'
def setUp(self): def setUp(self):
class cls(NavigationMixin, IntegrationPlugin): class NavigationCls(NavigationMixin, IntegrationPlugin):
NAVIGATION = [ NAVIGATION = [
{'name': 'aa', 'link': 'plugin:test:test_view'}, {'name': 'aa', 'link': 'plugin:test:test_view'},
] ]
self.mixin = cls() self.mixin = NavigationCls()
def test_function(self): def test_function(self):
# check right configuration # check right configuration
self.assertEqual(self.mixin.navigation, [{'name': 'aa', 'link': 'plugin:test:test_view'},]) self.assertEqual(self.mixin.navigation, [{'name': 'aa', 'link': 'plugin:test:test_view'},])
# check wrong links fails # check wrong links fails
with self.assertRaises(NotImplementedError): with self.assertRaises(NotImplementedError):
class cls(NavigationMixin, IntegrationPlugin): class NavigationCls(NavigationMixin, IntegrationPlugin):
NAVIGATION = ['aa', 'aa'] NAVIGATION = ['aa', 'aa']
cls() NavigationCls()