core/tests/helpers/test_init.py

39 lines
953 B
Python
Raw Normal View History

2016-03-09 09:25:50 +00:00
"""Test component helpers."""
# pylint: disable=protected-access
from collections import OrderedDict
from homeassistant import helpers
2015-09-13 05:56:49 +00:00
def test_extract_domain_configs():
"""Test the extraction of domain configuration."""
config = {
2019-07-31 19:25:30 +00:00
"zone": None,
"zoner": None,
"zone ": None,
"zone Hallo": None,
"zone 100": None,
}
2020-04-05 00:20:09 +00:00
assert {"zone", "zone Hallo", "zone 100"} == set(
2019-07-31 19:25:30 +00:00
helpers.extract_domain_configs(config, "zone")
)
def test_config_per_platform():
"""Test config per platform method."""
2019-07-31 19:25:30 +00:00
config = OrderedDict(
[
("zone", {"platform": "hello"}),
("zoner", None),
("zone Hallo", [1, {"platform": "hello 2"}]),
("zone 100", None),
]
)
assert [
2019-07-31 19:25:30 +00:00
("hello", config["zone"]),
(None, 1),
2019-07-31 19:25:30 +00:00
("hello 2", config["zone Hallo"][1]),
] == list(helpers.config_per_platform(config, "zone"))