2020-01-19 16:06:21 +01:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
import core.module
|
2020-01-26 14:06:09 +01:00
|
|
|
import core.widget
|
2020-01-19 16:06:21 +01:00
|
|
|
|
|
|
|
class module(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self._invalidModuleName = 'invalid-module-name'
|
|
|
|
self._validModuleName = 'test'
|
2020-01-26 14:06:09 +01:00
|
|
|
self.someWidget = core.widget.Widget('randomeWidgetContent')
|
|
|
|
self.anotherWidget = core.widget.Widget('more Widget content')
|
2020-01-19 16:06:21 +01:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_load_invalid_module(self):
|
|
|
|
module = core.module.load(self._invalidModuleName)
|
|
|
|
self.assertEqual('core.module', module.__class__.__module__, 'module must be a module object')
|
|
|
|
self.assertEqual('Error', module.__class__.__name__, 'an invalid module must be a core.module.Error')
|
|
|
|
|
|
|
|
def test_load_valid_module(self):
|
|
|
|
module = core.module.load(self._validModuleName)
|
|
|
|
self.assertEqual('modules.{}'.format(self._validModuleName), module.__class__.__module__, 'module must be a modules.<name> object')
|
|
|
|
self.assertEqual('Module', module.__class__.__name__, 'a valid module must have a Module class')
|
|
|
|
|
2020-01-26 14:06:09 +01:00
|
|
|
def test_empty_widgets(self):
|
|
|
|
module = core.module.Module(widgets=[])
|
|
|
|
self.assertEqual([], module.widgets())
|
|
|
|
|
|
|
|
def test_single_widget(self):
|
|
|
|
module = core.module.Module(widgets=self.someWidget)
|
|
|
|
self.assertEqual([self.someWidget], module.widgets())
|
|
|
|
|
|
|
|
def test_widget_list(self):
|
|
|
|
module = core.module.Module(widgets=[ self.someWidget, self.anotherWidget ])
|
|
|
|
self.assertEqual([ self.someWidget, self.anotherWidget ], module.widgets())
|
|
|
|
|
2020-01-19 16:06:21 +01:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|