bumblebee-status/pytests/modules/contrib/test_mpd.py

33 lines
1.1 KiB
Python
Raw Normal View History

2020-06-19 10:13:52 +02:00
import pytest
import core.config
import modules.contrib.mpd
@pytest.fixture
def mpd_module():
return modules.contrib.mpd.Module(config=core.config.Config([]), theme=None)
2020-06-19 12:12:30 +02:00
def _test_state(mocker, mpd_module, widget_name, expected_output):
widget = mocker.Mock()
2020-06-19 12:12:30 +02:00
widget.name = widget_name
return mpd_module.state(widget) == expected_output
def test_states(mocker, mpd_module):
assert _test_state(mocker, mpd_module, 'mpd.repeat', 'repeat-off')
assert _test_state(mocker, mpd_module, 'mpd.shuffle', 'shuffle-off')
assert _test_state(mocker, mpd_module, 'mpd.prev', 'prev')
assert _test_state(mocker, mpd_module, 'mpd.next', 'next')
def test_no_host(mpd_module):
assert mpd_module._hostcmd == ''
def test_host():
module_with_host = modules.contrib.mpd.Module(config=core.config.Config(['-p', 'mpd.host=sample-host']), theme=None)
assert module_with_host._hostcmd == ' -h sample-host'
def test_bad_layout():
pytest.raises(KeyError, modules.contrib.mpd.Module, config=core.config.Config(['-p', 'mpd.layout="mpd.inexistent"']), theme=None)
def test_hidden_on_creation(mpd_module):
assert mpd_module.hidden()