[tests] add more tests
This commit is contained in:
parent
eea3c758de
commit
7584366adc
4 changed files with 28 additions and 3 deletions
|
@ -14,6 +14,7 @@
|
||||||
- themes: use colors to improve theme readability
|
- themes: use colors to improve theme readability
|
||||||
- convert some stuff to simple attributes to reduce LOCs
|
- convert some stuff to simple attributes to reduce LOCs
|
||||||
- use widget index for bumblebee-ctl as alternative (??)
|
- use widget index for bumblebee-ctl as alternative (??)
|
||||||
|
- use pytest?
|
||||||
|
|
||||||
# documentation
|
# documentation
|
||||||
Add info about error widget and events for error logging
|
Add info about error widget and events for error logging
|
||||||
|
|
|
@ -52,8 +52,8 @@ class config(unittest.TestCase):
|
||||||
|
|
||||||
def test_logfile(self):
|
def test_logfile(self):
|
||||||
cfg = core.config.Config(["-f", "my-custom-logfile"])
|
cfg = core.config.Config(["-f", "my-custom-logfile"])
|
||||||
self.assertEquals(None, self.defaultConfig.logfile())
|
self.assertEqual(None, self.defaultConfig.logfile())
|
||||||
self.assertEquals("my-custom-logfile", cfg.logfile())
|
self.assertEqual("my-custom-logfile", cfg.logfile())
|
||||||
|
|
||||||
def test_all_modules(self):
|
def test_all_modules(self):
|
||||||
modules = core.config.all_modules()
|
modules = core.config.all_modules()
|
||||||
|
|
|
@ -7,6 +7,7 @@ import core.config
|
||||||
|
|
||||||
|
|
||||||
class TestModule(core.module.Module):
|
class TestModule(core.module.Module):
|
||||||
|
@core.decorators.never
|
||||||
def __init__(self, config=None, theme=None):
|
def __init__(self, config=None, theme=None):
|
||||||
config = core.config.Config([])
|
config = core.config.Config([])
|
||||||
super().__init__(config, theme, core.widget.Widget(self.get))
|
super().__init__(config, theme, core.widget.Widget(self.get))
|
||||||
|
@ -16,7 +17,6 @@ class TestModule(core.module.Module):
|
||||||
def get(self, widget):
|
def get(self, widget):
|
||||||
return self.text
|
return self.text
|
||||||
|
|
||||||
|
|
||||||
class config(unittest.TestCase):
|
class config(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.module = TestModule()
|
self.module = TestModule()
|
||||||
|
@ -24,6 +24,10 @@ class config(unittest.TestCase):
|
||||||
self.width = 10
|
self.width = 10
|
||||||
self.module.set("scrolling.width", self.width)
|
self.module.set("scrolling.width", self.width)
|
||||||
|
|
||||||
|
def test_never(self):
|
||||||
|
self.module = TestModule()
|
||||||
|
self.assertEqual("never", self.module.parameter("interval"))
|
||||||
|
|
||||||
def test_no_text(self):
|
def test_no_text(self):
|
||||||
self.assertEqual("", self.module.text)
|
self.assertEqual("", self.module.text)
|
||||||
self.assertEqual("", self.module.get(self.widget))
|
self.assertEqual("", self.module.get(self.widget))
|
||||||
|
|
|
@ -6,6 +6,7 @@ import shlex
|
||||||
import core.module
|
import core.module
|
||||||
import core.widget
|
import core.widget
|
||||||
import core.config
|
import core.config
|
||||||
|
import core.input
|
||||||
|
|
||||||
|
|
||||||
class TestModule(core.module.Module):
|
class TestModule(core.module.Module):
|
||||||
|
@ -137,5 +138,24 @@ class module(unittest.TestCase):
|
||||||
self.assertEqual(None, module.threshold_state(80, 80, 100))
|
self.assertEqual(None, module.threshold_state(80, 80, 100))
|
||||||
self.assertEqual(None, module.threshold_state(10, 80, 100))
|
self.assertEqual(None, module.threshold_state(10, 80, 100))
|
||||||
|
|
||||||
|
def test_configured_callbacks(self):
|
||||||
|
cfg = core.config.Config([])
|
||||||
|
module = TestModule(config=cfg, widgets=[self.someWidget, self.anotherWidget])
|
||||||
|
|
||||||
|
cmd = "sample-tool arg1 arg2 arg3"
|
||||||
|
module.set("left-click", cmd)
|
||||||
|
module.register_callbacks()
|
||||||
|
|
||||||
|
with unittest.mock.patch("core.input.util.cli") as cli:
|
||||||
|
cli.execute.return_value = ""
|
||||||
|
core.input.trigger({
|
||||||
|
"button": core.input.LEFT_MOUSE,
|
||||||
|
"instance": module.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
cli.execute.assert_called_once_with(
|
||||||
|
cmd, wait=False, shell=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue