Add the ability to reload homekit from yaml (#39326)

This commit is contained in:
J. Nick Koston 2020-08-28 09:46:45 -05:00 committed by GitHub
parent 400741006b
commit 414a59ae9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 182 additions and 18 deletions

View file

@ -2,11 +2,14 @@
import logging
from os import path
import pytest
from homeassistant import config
from homeassistant.const import SERVICE_RELOAD
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.reload import (
async_get_platform,
async_integration_yaml_config,
async_reload_integration_platforms,
async_setup_reload_service,
)
@ -106,5 +109,35 @@ async def test_setup_reload_service(hass):
assert len(setup_called) == 2
async def test_async_integration_yaml_config(hass):
"""Test loading yaml config for an integration."""
mock_integration(hass, MockModule(DOMAIN))
yaml_path = path.join(
_get_fixtures_base_path(),
"fixtures",
f"helpers/{DOMAIN}_configuration.yaml",
)
with patch.object(config, "YAML_CONFIG_FILE", yaml_path):
processed_config = await async_integration_yaml_config(hass, DOMAIN)
assert processed_config == {DOMAIN: [{"name": "one"}, {"name": "two"}]}
async def test_async_integration_missing_yaml_config(hass):
"""Test loading missing yaml config for an integration."""
mock_integration(hass, MockModule(DOMAIN))
yaml_path = path.join(
_get_fixtures_base_path(),
"fixtures",
"helpers/does_not_exist_configuration.yaml",
)
with pytest.raises(FileNotFoundError), patch.object(
config, "YAML_CONFIG_FILE", yaml_path
):
await async_integration_yaml_config(hass, DOMAIN)
def _get_fixtures_base_path():
return path.dirname(path.dirname(__file__))