[modules/kernel] Make widget dynamic (update if kernel changes)

This commit is contained in:
Tobias Witek 2020-03-06 14:31:08 +01:00
parent efc2e4f94e
commit 51faef9fd4
2 changed files with 9 additions and 6 deletions

View file

@ -9,6 +9,9 @@ import core.widget
class Module(core.module.Module): class Module(core.module.Module):
def __init__(self, config=None): def __init__(self, config=None):
super().__init__(config, core.widget.Widget(platform.release())) super().__init__(config, core.widget.Widget(self.full_text))
def full_text(self, widgets):
return platform.release()
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -5,11 +5,11 @@ import modules.core.kernel
class kernel(unittest.TestCase): class kernel(unittest.TestCase):
def setUp(self): def setUp(self):
self.someKernel = 'this-is-my-kernel' self.someKernel = 'this-is-my-kernel'
with unittest.mock.patch('modules.core.kernel.platform') as platform:
platform.release.return_value = self.someKernel
self.module = modules.core.kernel.Module() self.module = modules.core.kernel.Module()
def test_full_text(self): def test_full_text(self):
with unittest.mock.patch('modules.core.kernel.platform') as platform:
platform.release.return_value = self.someKernel
self.assertEqual(1, len(self.module.widgets())) self.assertEqual(1, len(self.module.widgets()))
self.assertEqual(self.someKernel, self.module.widget().full_text()) self.assertEqual(self.someKernel, self.module.widget().full_text())