<commit_before>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)

def _test_state(mocker, mpd_module, widget_name, expected_output):
    widget = mocker.Mock()
    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()
<commit_msg>Added mpd module tests for update and layout<commit_after>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)

def _test_state(mocker, mpd_module, widget_name, expected_output):
    widget = mocker.Mock()
    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()

def test_update_calls_load_song(mocker, mpd_module):
    mocker.patch.object(mpd_module, '_load_song')
    mpd_module.update()
    mpd_module._load_song.assert_called_once()

def test_default_layout(mpd_module):
    assert mpd_module._layout == "mpd.prev mpd.main mpd.next mpd.shuffle mpd.repeat"

{'fraction_non_alphanumeric': 0.13493530499075784, 'fraction_numerical': 0.0, 'mean_word_length': 5.536231884057971, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7539554', 'n_tokens_mistral': 977, 'n_tokens_neox': 978, 'n_words': 167}