mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Make cv.empty_config_schema log an error instead of raise (#93646)
* Make cv.empty_config_schema log an error instead of raise * Add test * Update homeassistant/helpers/config_validation.py Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> --------- Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
@@ -1468,3 +1468,25 @@ def test_positive_time_period_template() -> None:
|
||||
schema("{{ 'invalid' }}")
|
||||
schema({"{{ 'invalid' }}": 5})
|
||||
schema({"minutes": "{{ 'invalid' }}"})
|
||||
|
||||
|
||||
def test_empty_schema(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test if the current module cannot be inspected."""
|
||||
expected_message = (
|
||||
"The test_domain integration does not support any configuration parameters"
|
||||
)
|
||||
|
||||
cv.empty_config_schema("test_domain")({})
|
||||
assert expected_message not in caplog.text
|
||||
|
||||
cv.empty_config_schema("test_domain")({"test_domain": {}})
|
||||
assert expected_message not in caplog.text
|
||||
|
||||
cv.empty_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
|
||||
assert expected_message in caplog.text
|
||||
|
||||
|
||||
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"}})
|
||||
|
||||
Reference in New Issue
Block a user