[tests] Maybe patching the platform call fixes the issue with Travis
This commit is contained in:
parent
11c68310bb
commit
935b50a23b
1 changed files with 15 additions and 10 deletions
|
@ -16,17 +16,27 @@ class TestGenericModules(unittest.TestCase):
|
||||||
engine.input = mock.Mock()
|
engine.input = mock.Mock()
|
||||||
config = Config()
|
config = Config()
|
||||||
self.objects = {}
|
self.objects = {}
|
||||||
|
|
||||||
|
self.popen = mocks.MockPopen()
|
||||||
|
self.popen.mock.communicate.return_value = (str.encode("1"), "error")
|
||||||
|
self.popen.mock.returncode = 0
|
||||||
|
|
||||||
|
self._platform = mock.patch("bumblebee.modules.kernel.platform")
|
||||||
|
self.platform = self._platform.start()
|
||||||
|
self.platform.release.return_value = "unknown linux v1"
|
||||||
|
|
||||||
for mod in all_modules():
|
for mod in all_modules():
|
||||||
cls = importlib.import_module("bumblebee.modules.{}".format(mod["name"]))
|
name = "bumblebee.modules.{}".format(mod["name"])
|
||||||
|
cls = importlib.import_module(name)
|
||||||
self.objects[mod["name"]] = getattr(cls, "Module")(engine, {"config": config})
|
self.objects[mod["name"]] = getattr(cls, "Module")(engine, {"config": config})
|
||||||
for widget in self.objects[mod["name"]].widgets():
|
for widget in self.objects[mod["name"]].widgets():
|
||||||
self.assertEquals(widget.get("variable", None), None)
|
self.assertEquals(widget.get("variable", None), None)
|
||||||
|
|
||||||
def test_widgets(self):
|
def tearDown(self):
|
||||||
popen = mocks.MockPopen()
|
self._platform.stop()
|
||||||
popen.mock.communicate.return_value = (str.encode("1"), "error")
|
self.popen.cleanup()
|
||||||
popen.mock.returncode = 0
|
|
||||||
|
|
||||||
|
def test_widgets(self):
|
||||||
for mod in self.objects:
|
for mod in self.objects:
|
||||||
widgets = self.objects[mod].widgets()
|
widgets = self.objects[mod].widgets()
|
||||||
for widget in widgets:
|
for widget in widgets:
|
||||||
|
@ -37,17 +47,12 @@ class TestGenericModules(unittest.TestCase):
|
||||||
widget.set("variable", "value")
|
widget.set("variable", "value")
|
||||||
self.assertEquals(widget.get("variable", None), "value")
|
self.assertEquals(widget.get("variable", None), "value")
|
||||||
self.assertTrue(isinstance(widget.full_text(), str) or isinstance(widget.full_text(), unicode))
|
self.assertTrue(isinstance(widget.full_text(), str) or isinstance(widget.full_text(), unicode))
|
||||||
popen.cleanup()
|
|
||||||
|
|
||||||
def test_update(self):
|
def test_update(self):
|
||||||
popen = mocks.MockPopen()
|
|
||||||
popen.mock.communicate.return_value = (str.encode("1"), "error")
|
|
||||||
popen.mock.returncode = 0
|
|
||||||
for mod in self.objects:
|
for mod in self.objects:
|
||||||
widgets = self.objects[mod].widgets()
|
widgets = self.objects[mod].widgets()
|
||||||
self.objects[mod].update(widgets)
|
self.objects[mod].update(widgets)
|
||||||
self.test_widgets()
|
self.test_widgets()
|
||||||
self.assertEquals(widgets, self.objects[mod].widgets())
|
self.assertEquals(widgets, self.objects[mod].widgets())
|
||||||
popen.cleanup()
|
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue