a045962d00
Re-add the NIC module with all its functionality (hopefully...). This introduces a new concept: Instead of having separate queries for critical and warning (which really are just another set of states), a module can now return a list of states for each widget. All the state information is then merged together into a single theme. So, for instance, the NIC module can return a state saying "critical - wlan-down", which applies the theme information for both "critical" and "wlan-down". see #23
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
# pylint: disable=C0103,C0111
|
|
|
|
import unittest
|
|
import importlib
|
|
|
|
from bumblebee.engine import all_modules
|
|
from bumblebee.config import Config
|
|
from tests.util import assertWidgetAttributes, MockEngine
|
|
|
|
class TestGenericModules(unittest.TestCase):
|
|
def setUp(self):
|
|
engine = MockEngine()
|
|
config = Config()
|
|
self.objects = {}
|
|
for mod in all_modules():
|
|
cls = importlib.import_module("bumblebee.modules.{}".format(mod["name"]))
|
|
self.objects[mod["name"]] = getattr(cls, "Module")(engine, {"config": config})
|
|
for widget in self.objects[mod["name"]].widgets():
|
|
self.assertEquals(widget.get("variable", None), None)
|
|
|
|
def test_widgets(self):
|
|
for mod in self.objects:
|
|
widgets = self.objects[mod].widgets()
|
|
for widget in widgets:
|
|
widget.link_module(self.objects[mod])
|
|
self.assertEquals(widget.module, mod)
|
|
assertWidgetAttributes(self, widget)
|
|
widget.set("variable", "value")
|
|
self.assertEquals(widget.get("variable", None), "value")
|
|
|
|
def test_update(self):
|
|
for mod in self.objects:
|
|
widgets = self.objects[mod].widgets()
|
|
self.objects[mod].update(widgets)
|
|
self.test_widgets()
|
|
self.assertEquals(widgets, self.objects[mod].widgets())
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|