2016-03-09 09:25:50 +00:00
|
|
|
"""Test component helpers."""
|
2016-10-30 21:18:53 +00:00
|
|
|
# pylint: disable=protected-access
|
2016-06-11 05:53:31 +00:00
|
|
|
from collections import OrderedDict
|
2014-12-07 07:57:02 +00:00
|
|
|
|
2016-01-24 06:57:14 +00:00
|
|
|
from homeassistant import helpers
|
2014-12-07 07:57:02 +00:00
|
|
|
|
2015-09-13 05:56:49 +00:00
|
|
|
|
2019-04-30 16:20:38 +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,
|
2019-04-30 16:20:38 +00:00
|
|
|
}
|
|
|
|
|
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")
|
|
|
|
)
|
2019-04-30 16:20:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
]
|
|
|
|
)
|
2019-04-30 16:20:38 +00:00
|
|
|
|
|
|
|
assert [
|
2019-07-31 19:25:30 +00:00
|
|
|
("hello", config["zone"]),
|
2019-04-30 16:20:38 +00:00
|
|
|
(None, 1),
|
2019-07-31 19:25:30 +00:00
|
|
|
("hello 2", config["zone Hallo"][1]),
|
|
|
|
] == list(helpers.config_per_platform(config, "zone"))
|