add tests for solaar.py

This commit is contained in:
Jan Fader 2021-10-26 21:52:15 +02:00
parent dced20bf89
commit 2cb72fcc30
No known key found for this signature in database
GPG key ID: 1A6BDEFB0E27FA44

View file

@ -0,0 +1,32 @@
import pytest
import util.cli
import core.config
import modules.contrib.solaar
@pytest.fixture
def module():
module = modules.contrib.solaar.Module(
config=core.config.Config([]),
theme=None
)
yield module
def test_load_module():
__import__("modules.contrib.solaar")
def test_with_unknown_code(module, mocker):
mocker.patch('util.cli.execute', return_value=(99, 'error'))
logger = mocker.patch('logging.error')
module.update()
logger.assert_called_with('solaar exited with {}: {}'.format(99, 'error'))
widget = module.widget()
assert module.state(widget) == 'warning'
assert module.hidden() == False