2020-10-04 20:57:48 +02:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
import util.cli
|
|
|
|
import core.config
|
|
|
|
import modules.contrib.dunstctl
|
|
|
|
|
|
|
|
def build_module():
|
|
|
|
return modules.contrib.dunstctl.Module(
|
|
|
|
config=core.config.Config([]),
|
|
|
|
theme=None
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_load_module():
|
|
|
|
__import__("modules.contrib.dunstctl")
|
|
|
|
|
|
|
|
def test_dunst_running(mocker):
|
2020-10-18 15:34:52 +02:00
|
|
|
command = mocker.patch('util.cli.execute', return_value=(0, "false"))
|
2020-10-04 20:57:48 +02:00
|
|
|
|
|
|
|
module = build_module()
|
|
|
|
module.update()
|
|
|
|
widget = module.widget()
|
2020-10-18 15:34:52 +02:00
|
|
|
|
|
|
|
actual = module.state(widget)
|
|
|
|
command.assert_called_with('dunstctl is-paused', return_exitcode=True, ignore_errors=True)
|
|
|
|
assert actual == ['unmuted']
|
2020-10-04 20:57:48 +02:00
|
|
|
|
|
|
|
def test_dunst_paused(mocker):
|
2020-10-18 15:34:52 +02:00
|
|
|
command = mocker.patch('util.cli.execute', return_value=(0, "true"))
|
2020-10-04 20:57:48 +02:00
|
|
|
|
|
|
|
module = build_module()
|
|
|
|
module.update()
|
|
|
|
widget = module.widget()
|
|
|
|
|
2020-10-18 15:34:52 +02:00
|
|
|
actual = module.state(widget)
|
|
|
|
command.assert_called_with('dunstctl is-paused', return_exitcode=True, ignore_errors=True)
|
|
|
|
assert actual == ['muted', 'warning']
|
2020-10-04 20:57:48 +02:00
|
|
|
|
2020-10-18 15:34:52 +02:00
|
|
|
def test_dunst_off(mocker):
|
|
|
|
command = mocker.patch('util.cli.execute', return_value=(1, "dontcare"))
|
2020-10-04 20:57:48 +02:00
|
|
|
|
|
|
|
module = build_module()
|
2020-10-18 15:34:52 +02:00
|
|
|
module.update()
|
|
|
|
widget = module.widget()
|
2020-10-04 20:57:48 +02:00
|
|
|
|
2020-10-18 15:34:52 +02:00
|
|
|
actual = module.state(widget)
|
|
|
|
command.assert_called_with('dunstctl is-paused', return_exitcode=True, ignore_errors=True)
|
|
|
|
assert actual == ['unknown', 'critical']
|