Provide alternative dunstctl implementation
This commit is contained in:
parent
68bd6f8ef8
commit
3c0499ba56
5 changed files with 55 additions and 59 deletions
|
@ -14,54 +14,34 @@ def test_load_module():
|
|||
__import__("modules.contrib.dunstctl")
|
||||
|
||||
def test_dunst_running(mocker):
|
||||
command = mocker.patch('util.cli.execute', return_value='false')
|
||||
command = mocker.patch('util.cli.execute', return_value=(0, "false"))
|
||||
|
||||
module = build_module()
|
||||
module.update()
|
||||
|
||||
command.assert_called_with('dunstctl is-paused')
|
||||
|
||||
widget = module.widget()
|
||||
assert module.state(widget) == ['unmuted']
|
||||
|
||||
actual = module.state(widget)
|
||||
command.assert_called_with('dunstctl is-paused', return_exitcode=True, ignore_errors=True)
|
||||
assert actual == ['unmuted']
|
||||
|
||||
def test_dunst_paused(mocker):
|
||||
command = mocker.patch('util.cli.execute', return_value='true')
|
||||
command = mocker.patch('util.cli.execute', return_value=(0, "true"))
|
||||
|
||||
module = build_module()
|
||||
module.update()
|
||||
|
||||
command.assert_called_with('dunstctl is-paused')
|
||||
|
||||
widget = module.widget()
|
||||
assert module.state(widget) == ['muted', 'warning']
|
||||
|
||||
def test_toggle_status_pause(mocker):
|
||||
command = mocker.patch('util.cli.execute')
|
||||
command.side_effect = ['true', 'true', None]
|
||||
actual = module.state(widget)
|
||||
command.assert_called_with('dunstctl is-paused', return_exitcode=True, ignore_errors=True)
|
||||
assert actual == ['muted', 'warning']
|
||||
|
||||
def test_dunst_off(mocker):
|
||||
command = mocker.patch('util.cli.execute', return_value=(1, "dontcare"))
|
||||
|
||||
module = build_module()
|
||||
module.toggle_status(False)
|
||||
|
||||
command.assert_any_call('dunstctl set-paused false')
|
||||
|
||||
def test_toggle_status_unpause(mocker):
|
||||
command = mocker.patch('util.cli.execute')
|
||||
command.side_effect = ['false', 'false', None]
|
||||
|
||||
module = build_module()
|
||||
module.toggle_status(False)
|
||||
|
||||
command.assert_called_with('dunstctl set-paused true')
|
||||
|
||||
def test_input_register(mocker):
|
||||
command = mocker.patch('util.cli.execute')
|
||||
input_register = mocker.patch('core.input.register')
|
||||
|
||||
module = build_module()
|
||||
|
||||
input_register.assert_called_with(
|
||||
module,
|
||||
button=core.input.LEFT_MOUSE,
|
||||
cmd=module.toggle_status
|
||||
)
|
||||
module.update()
|
||||
widget = module.widget()
|
||||
|
||||
actual = module.state(widget)
|
||||
command.assert_called_with('dunstctl is-paused', return_exitcode=True, ignore_errors=True)
|
||||
assert actual == ['unknown', 'critical']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue