[tests/module] Test generation of error widget

When a module/widget throws, an error widget should be produced.
This commit is contained in:
Tobias Witek 2020-03-04 21:06:09 +01:00
parent 533b8ca0cc
commit d19eb72296

View file

@ -7,7 +7,10 @@ import core.widget
import core.config import core.config
class TestModule(core.module.Module): class TestModule(core.module.Module):
pass def update(self):
if self.fail:
raise Exception(self.error)
pass
class module(unittest.TestCase): class module(unittest.TestCase):
def setUp(self): def setUp(self):
@ -68,4 +71,13 @@ class module(unittest.TestCase):
module = TestModule(config=cfg) module = TestModule(config=cfg)
self.assertEqual(None, module.parameter('foo')) self.assertEqual(None, module.parameter('foo'))
def test_error_widget(self):
cfg = core.config.Config([])
module = TestModule(config=cfg)
module.fail = True
module.error = '!!'
module.update_wrapper()
self.assertEqual(1, len(module.widgets()))
self.assertEqual('error: !!', module.widget().full_text())
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4