2016-12-04 18:10:04 +01:00
|
|
|
# pylint: disable=C0103,C0111,W0613
|
2016-12-04 12:53:18 +01:00
|
|
|
|
2016-12-09 22:28:04 +01:00
|
|
|
import shlex
|
|
|
|
import subprocess
|
|
|
|
|
2016-12-04 17:45:42 +01:00
|
|
|
from bumblebee.output import Widget
|
|
|
|
|
|
|
|
def assertWidgetAttributes(test, widget):
|
|
|
|
test.assertTrue(isinstance(widget, Widget))
|
|
|
|
test.assertTrue(hasattr(widget, "full_text"))
|
|
|
|
|
2016-12-09 22:28:04 +01:00
|
|
|
def assertPopen(output, cmd):
|
|
|
|
res = shlex.split(cmd)
|
|
|
|
output.assert_called_with(res,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
|
2016-12-09 19:29:16 +01:00
|
|
|
class MockInput(object):
|
|
|
|
def start(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def stop(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def register_callback(self, obj, button, cmd):
|
|
|
|
pass
|
|
|
|
|
2016-12-09 07:27:01 +01:00
|
|
|
class MockEngine(object):
|
2016-12-09 19:29:16 +01:00
|
|
|
def __init__(self):
|
|
|
|
self.input = MockInput()
|
2016-12-09 07:27:01 +01:00
|
|
|
|
2016-12-10 07:47:24 +01:00
|
|
|
class MockConfig(object):
|
|
|
|
def get(self, name, default):
|
|
|
|
return default
|
|
|
|
|
2016-12-04 17:45:42 +01:00
|
|
|
class MockOutput(object):
|
|
|
|
def start(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def stop(self):
|
|
|
|
pass
|
|
|
|
|
2016-12-09 19:29:16 +01:00
|
|
|
def draw(self, widget, engine, module):
|
2016-12-04 17:45:42 +01:00
|
|
|
engine.stop()
|
|
|
|
|
2016-12-08 12:44:52 +01:00
|
|
|
def begin(self):
|
|
|
|
pass
|
|
|
|
|
2016-12-04 17:45:42 +01:00
|
|
|
def flush(self):
|
|
|
|
pass
|
|
|
|
|
2016-12-08 12:44:52 +01:00
|
|
|
def end(self):
|
|
|
|
pass
|
|
|
|
|
2016-12-09 19:29:16 +01:00
|
|
|
class MockModule(object):
|
|
|
|
def __init__(self, engine=None, config=None):
|
|
|
|
self.id = None
|
|
|
|
|
2016-12-09 13:32:22 +01:00
|
|
|
class MockWidget(Widget):
|
2016-12-04 12:53:18 +01:00
|
|
|
def __init__(self, text):
|
2016-12-09 16:33:29 +01:00
|
|
|
super(MockWidget, self).__init__(text)
|
2016-12-04 12:53:18 +01:00
|
|
|
self._text = text
|
2016-12-09 11:49:59 +01:00
|
|
|
self.module = None
|
2016-12-09 13:32:22 +01:00
|
|
|
self.attr_state = "state-default"
|
2016-12-09 19:29:16 +01:00
|
|
|
self.id = "none"
|
2016-12-09 13:32:22 +01:00
|
|
|
|
|
|
|
def state(self):
|
|
|
|
return self.attr_state
|
2016-12-04 12:53:18 +01:00
|
|
|
|
2016-12-08 08:44:54 +01:00
|
|
|
def update(self, widgets):
|
|
|
|
pass
|
|
|
|
|
2016-12-04 17:45:42 +01:00
|
|
|
def full_text(self):
|
2016-12-04 12:53:18 +01:00
|
|
|
return self._text
|
|
|
|
|
2016-12-08 11:31:20 +01:00
|
|
|
class MockTheme(object):
|
|
|
|
def __init__(self):
|
2016-12-09 11:42:02 +01:00
|
|
|
self.attr_prefix = None
|
|
|
|
self.attr_suffix = None
|
|
|
|
self.attr_fg = None
|
|
|
|
self.attr_bg = None
|
2016-12-09 12:55:16 +01:00
|
|
|
self.attr_separator = None
|
|
|
|
self.attr_separator_block_width = 0
|
2016-12-09 08:58:45 +01:00
|
|
|
|
2016-12-09 13:06:08 +01:00
|
|
|
def padding(self, widget):
|
|
|
|
return ""
|
|
|
|
|
2016-12-09 12:28:39 +01:00
|
|
|
def reset(self):
|
|
|
|
pass
|
|
|
|
|
2016-12-09 12:55:16 +01:00
|
|
|
def separator_block_width(self, widget):
|
|
|
|
return self.attr_separator_block_width
|
|
|
|
|
|
|
|
def separator(self, widget):
|
|
|
|
return self.attr_separator
|
|
|
|
|
2016-12-09 13:06:08 +01:00
|
|
|
def prefix(self, widget, default=None):
|
2016-12-09 11:42:02 +01:00
|
|
|
return self.attr_prefix
|
2016-12-08 11:31:20 +01:00
|
|
|
|
2016-12-09 13:06:08 +01:00
|
|
|
def suffix(self, widget, default=None):
|
2016-12-09 11:42:02 +01:00
|
|
|
return self.attr_suffix
|
2016-12-08 11:31:20 +01:00
|
|
|
|
2016-12-09 08:58:45 +01:00
|
|
|
def fg(self, widget):
|
2016-12-09 11:42:02 +01:00
|
|
|
return self.attr_fg
|
2016-12-09 08:58:45 +01:00
|
|
|
|
|
|
|
def bg(self, widget):
|
2016-12-09 11:42:02 +01:00
|
|
|
return self.attr_bg
|
2016-12-09 08:58:45 +01:00
|
|
|
|
2016-12-04 12:53:18 +01:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|