hass-core/tests/helpers/test_init.py
Erik Montnemery 407e0c58f9 Migrate tests to pytest (#23544)
* Migrate tests to pytest

* Fixup

* Use loop fixture in test_check_config

* Lint
2019-04-30 09:20:38 -07:00

35 lines
920 B
Python

"""Test component helpers."""
# pylint: disable=protected-access
from collections import OrderedDict
from homeassistant import helpers
def test_extract_domain_configs():
"""Test the extraction of domain configuration."""
config = {
'zone': None,
'zoner': None,
'zone ': None,
'zone Hallo': None,
'zone 100': None,
}
assert set(['zone', 'zone Hallo', 'zone 100']) == \
set(helpers.extract_domain_configs(config, 'zone'))
def test_config_per_platform():
"""Test config per platform method."""
config = OrderedDict([
('zone', {'platform': 'hello'}),
('zoner', None),
('zone Hallo', [1, {'platform': 'hello 2'}]),
('zone 100', None),
])
assert [
('hello', config['zone']),
(None, 1),
('hello 2', config['zone Hallo'][1]),
] == list(helpers.config_per_platform(config, 'zone'))