Add CONFIG_SCHEMA to broadlink (#93854)
* Add CONFIG_SCHEMA to broadlink * Simplify error message * Rename to no_yaml_config_schema * Add tests * Raise issue * Tweak repairs issue description and title * Update homeassistant/helpers/config_validation.py * Add link * Update homeassistant/components/homeassistant/strings.json Co-authored-by: Franck Nijhof <git@frenck.dev> * Fix logic, add test --------- Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
f73754ff58
commit
e0db9ab041
4 changed files with 110 additions and 5 deletions
|
@ -11,8 +11,13 @@ import pytest
|
|||
import voluptuous as vol
|
||||
|
||||
import homeassistant
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv, selector, template
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||
from homeassistant.helpers import (
|
||||
config_validation as cv,
|
||||
issue_registry as ir,
|
||||
selector,
|
||||
template,
|
||||
)
|
||||
|
||||
|
||||
def test_boolean() -> None:
|
||||
|
@ -1475,7 +1480,7 @@ def test_positive_time_period_template() -> None:
|
|||
|
||||
|
||||
def test_empty_schema(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test if the current module cannot be inspected."""
|
||||
"""Test empty_config_schema."""
|
||||
expected_message = (
|
||||
"The test_domain integration does not support any configuration parameters"
|
||||
)
|
||||
|
@ -1494,3 +1499,50 @@ def test_empty_schema_cant_find_module() -> None:
|
|||
"""Test if the current module cannot be inspected."""
|
||||
with patch("inspect.getmodule", return_value=None):
|
||||
cv.empty_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
|
||||
|
||||
|
||||
def test_no_yaml_schema(hass: HomeAssistant, caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test no_yaml_config_schema."""
|
||||
expected_issue = "integration_key_no_support_test_domain"
|
||||
expected_message = (
|
||||
"The test_domain integration does not support YAML setup, please remove "
|
||||
"it from your configuration"
|
||||
)
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
cv.no_yaml_config_schema("test_domain")({})
|
||||
assert expected_message not in caplog.text
|
||||
assert not issue_registry.async_get_issue(HOMEASSISTANT_DOMAIN, expected_issue)
|
||||
|
||||
cv.no_yaml_config_schema("test_domain")({"test_domain": {}})
|
||||
assert expected_message in caplog.text
|
||||
assert issue_registry.async_get_issue(HOMEASSISTANT_DOMAIN, expected_issue)
|
||||
issue_registry.async_delete(HOMEASSISTANT_DOMAIN, expected_issue)
|
||||
|
||||
cv.no_yaml_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
|
||||
assert expected_message in caplog.text
|
||||
assert issue_registry.async_get_issue(HOMEASSISTANT_DOMAIN, expected_issue)
|
||||
|
||||
|
||||
def test_no_yaml_schema_cant_find_module() -> None:
|
||||
"""Test if the current module cannot be inspected."""
|
||||
with patch("inspect.getmodule", return_value=None):
|
||||
cv.no_yaml_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
|
||||
|
||||
|
||||
def test_no_yaml_schema_no_hass(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test if the the hass context var is not set in our context."""
|
||||
with patch(
|
||||
"homeassistant.helpers.config_validation.async_get_hass",
|
||||
side_effect=LookupError,
|
||||
):
|
||||
cv.no_yaml_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
|
||||
expected_message = (
|
||||
"The test_domain integration does not support YAML setup, please remove "
|
||||
"it from your configuration"
|
||||
)
|
||||
assert expected_message in caplog.text
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert not issue_registry.issues
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue