2016-12-09 07:27:01 +01:00
|
|
|
# pylint: disable=C0103,C0111
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import importlib
|
|
|
|
|
2016-12-09 08:43:14 +01:00
|
|
|
from bumblebee.engine import all_modules
|
2016-12-09 08:23:53 +01:00
|
|
|
from bumblebee.config import Config
|
2016-12-09 07:27:01 +01:00
|
|
|
from tests.util import assertWidgetAttributes, MockEngine
|
|
|
|
|
|
|
|
class TestGenericModules(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
engine = MockEngine()
|
2016-12-09 08:23:53 +01:00
|
|
|
config = Config()
|
2016-12-09 07:27:01 +01:00
|
|
|
self.objects = {}
|
2016-12-09 08:43:14 +01:00
|
|
|
for mod in all_modules():
|
2016-12-09 07:27:01 +01:00
|
|
|
cls = importlib.import_module("bumblebee.modules.{}".format(mod["name"]))
|
2016-12-09 08:43:14 +01:00
|
|
|
self.objects[mod["name"]] = getattr(cls, "Module")(engine, {"config": config})
|
2016-12-10 11:25:02 +01:00
|
|
|
for widget in self.objects[mod["name"]].widgets():
|
|
|
|
self.assertEquals(widget.get("variable", None), None)
|
2016-12-09 07:27:01 +01:00
|
|
|
|
|
|
|
def test_widgets(self):
|
|
|
|
for mod in self.objects:
|
|
|
|
widgets = self.objects[mod].widgets()
|
|
|
|
for widget in widgets:
|
2016-12-09 11:49:59 +01:00
|
|
|
widget.link_module(self.objects[mod])
|
|
|
|
self.assertEquals(widget.module, mod)
|
2016-12-09 07:27:01 +01:00
|
|
|
assertWidgetAttributes(self, widget)
|
2016-12-10 11:25:02 +01:00
|
|
|
widget.set("variable", "value")
|
|
|
|
self.assertEquals(widget.get("variable", None), "value")
|
2016-12-09 07:27:01 +01:00
|
|
|
|
2016-12-10 19:35:38 +01:00
|
|
|
@mock.patch("subprocess.Popen")
|
|
|
|
def test_update(self, mock_output):
|
2016-12-09 07:27:01 +01:00
|
|
|
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
|