more coverage

This commit is contained in:
Matthias 2021-09-28 22:28:39 +02:00
parent e41e2586a6
commit c94e1347d3
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -28,14 +28,23 @@ class SettingsMixinTest(BaseMixinDefinition, TestCase):
class SettingsCls(SettingsMixin, IntegrationPlugin): class SettingsCls(SettingsMixin, IntegrationPlugin):
SETTINGS = self.TEST_SETTINGS SETTINGS = self.TEST_SETTINGS
self.mixin = SettingsCls() self.mixin = SettingsCls()
class NoSettingsCls(SettingsMixin, IntegrationPlugin):
pass
self.mixin_nothing = NoSettingsCls()
def test_function(self): def test_function(self):
# settings variable # settings variable
self.assertEqual(self.mixin.settings, self.TEST_SETTINGS) self.assertEqual(self.mixin.settings, self.TEST_SETTINGS)
# settings pattern # settings pattern
target_pattern = {f'PLUGIN_{self.mixin.plugin_name().upper()}_{key}': value for key, value in self.mixin.settings.items()} target_pattern = {f'PLUGIN_{self.mixin.plugin_name().upper()}_{key}': value for key, value in self.mixin.settings.items()}
self.assertEqual(self.mixin.settingspatterns, target_pattern) self.assertEqual(self.mixin.settingspatterns, target_pattern)
# no settings
self.assertIsNone(self.mixin_nothing.settings)
self.assertIsNone(self.mixin_nothing.settingspatterns)
class UrlsMixinTest(BaseMixinDefinition, TestCase): class UrlsMixinTest(BaseMixinDefinition, TestCase):
MIXIN_HUMAN_NAME = 'URLs' MIXIN_HUMAN_NAME = 'URLs'
@ -48,6 +57,9 @@ class UrlsMixinTest(BaseMixinDefinition, TestCase):
return 'ccc' return 'ccc'
URLS = [url('test', test, name='test'), ] URLS = [url('test', test, name='test'), ]
self.mixin = UrlsCls() self.mixin = UrlsCls()
class NoUrlsCls(UrlsMixin, IntegrationPlugin):
pass
self.mixin_nothing = NoUrlsCls()
def test_function(self): def test_function(self):
plg_name = self.mixin.plugin_name() plg_name = self.mixin.plugin_name()
@ -60,6 +72,13 @@ class UrlsMixinTest(BaseMixinDefinition, TestCase):
target_pattern = url(f'^{plg_name}/', include((self.mixin.urls, plg_name)), name=plg_name) target_pattern = url(f'^{plg_name}/', include((self.mixin.urls, plg_name)), name=plg_name)
self.assertEqual(self.mixin.urlpatterns.reverse_dict, target_pattern.reverse_dict) self.assertEqual(self.mixin.urlpatterns.reverse_dict, target_pattern.reverse_dict)
# resolve the view
self.assertEqual(self.mixin.urlpatterns, 'ccc')
# no url
self.assertIsNone(self.mixin_nothing.urls)
self.assertIsNone(self.mixin_nothing.urlpatterns)
class NavigationMixinTest(BaseMixinDefinition, TestCase): class NavigationMixinTest(BaseMixinDefinition, TestCase):
MIXIN_HUMAN_NAME = 'Navigation Links' MIXIN_HUMAN_NAME = 'Navigation Links'