parent
8e3b58dc28
commit
f0dc39a903
|
@ -1489,7 +1489,7 @@ async def test_setup_does_base_platforms_first(hass: HomeAssistant) -> None:
|
||||||
assert order[3:] == ["root", "first_dep", "second_dep"]
|
assert order[3:] == ["root", "first_dep", "second_dep"]
|
||||||
|
|
||||||
|
|
||||||
def test_should_rollover_is_always_false():
|
def test_should_rollover_is_always_false() -> None:
|
||||||
"""Test that shouldRollover always returns False."""
|
"""Test that shouldRollover always returns False."""
|
||||||
assert (
|
assert (
|
||||||
bootstrap._RotatingFileHandlerWithoutShouldRollOver(
|
bootstrap._RotatingFileHandlerWithoutShouldRollOver(
|
||||||
|
|
|
@ -8,10 +8,11 @@ import logging
|
||||||
import os
|
import os
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
from typing_extensions import Generator
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from voluptuous import Invalid, MultipleInvalid
|
from voluptuous import Invalid, MultipleInvalid
|
||||||
import yaml
|
import yaml
|
||||||
|
@ -1082,7 +1083,9 @@ async def test_check_ha_config_file_wrong(mock_check, hass: HomeAssistant) -> No
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@pytest.mark.usefixtures("mock_hass_config")
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_async_hass_config_yaml_merge(merge_log_err, hass: HomeAssistant) -> None:
|
async def test_async_hass_config_yaml_merge(
|
||||||
|
merge_log_err: MagicMock, hass: HomeAssistant
|
||||||
|
) -> None:
|
||||||
"""Test merge during async config reload."""
|
"""Test merge during async config reload."""
|
||||||
conf = await config_util.async_hass_config_yaml(hass)
|
conf = await config_util.async_hass_config_yaml(hass)
|
||||||
|
|
||||||
|
@ -1094,13 +1097,13 @@ async def test_async_hass_config_yaml_merge(merge_log_err, hass: HomeAssistant)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def merge_log_err(hass):
|
def merge_log_err() -> Generator[MagicMock]:
|
||||||
"""Patch _merge_log_error from packages."""
|
"""Patch _merge_log_error from packages."""
|
||||||
with patch("homeassistant.config._LOGGER.error") as logerr:
|
with patch("homeassistant.config._LOGGER.error") as logerr:
|
||||||
yield logerr
|
yield logerr
|
||||||
|
|
||||||
|
|
||||||
async def test_merge(merge_log_err, hass: HomeAssistant) -> None:
|
async def test_merge(merge_log_err: MagicMock, hass: HomeAssistant) -> None:
|
||||||
"""Test if we can merge packages."""
|
"""Test if we can merge packages."""
|
||||||
packages = {
|
packages = {
|
||||||
"pack_dict": {"input_boolean": {"ib1": None}},
|
"pack_dict": {"input_boolean": {"ib1": None}},
|
||||||
|
@ -1135,7 +1138,7 @@ async def test_merge(merge_log_err, hass: HomeAssistant) -> None:
|
||||||
assert isinstance(config["wake_on_lan"], OrderedDict)
|
assert isinstance(config["wake_on_lan"], OrderedDict)
|
||||||
|
|
||||||
|
|
||||||
async def test_merge_try_falsy(merge_log_err, hass: HomeAssistant) -> None:
|
async def test_merge_try_falsy(merge_log_err: MagicMock, hass: HomeAssistant) -> None:
|
||||||
"""Ensure we don't add falsy items like empty OrderedDict() to list."""
|
"""Ensure we don't add falsy items like empty OrderedDict() to list."""
|
||||||
packages = {
|
packages = {
|
||||||
"pack_falsy_to_lst": {"automation": OrderedDict()},
|
"pack_falsy_to_lst": {"automation": OrderedDict()},
|
||||||
|
@ -1154,7 +1157,7 @@ async def test_merge_try_falsy(merge_log_err, hass: HomeAssistant) -> None:
|
||||||
assert len(config["light"]) == 1
|
assert len(config["light"]) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_merge_new(merge_log_err, hass: HomeAssistant) -> None:
|
async def test_merge_new(merge_log_err: MagicMock, hass: HomeAssistant) -> None:
|
||||||
"""Test adding new components to outer scope."""
|
"""Test adding new components to outer scope."""
|
||||||
packages = {
|
packages = {
|
||||||
"pack_1": {"light": [{"platform": "one"}]},
|
"pack_1": {"light": [{"platform": "one"}]},
|
||||||
|
@ -1175,7 +1178,9 @@ async def test_merge_new(merge_log_err, hass: HomeAssistant) -> None:
|
||||||
assert len(config["panel_custom"]) == 1
|
assert len(config["panel_custom"]) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_merge_type_mismatch(merge_log_err, hass: HomeAssistant) -> None:
|
async def test_merge_type_mismatch(
|
||||||
|
merge_log_err: MagicMock, hass: HomeAssistant
|
||||||
|
) -> None:
|
||||||
"""Test if we have a type mismatch for packages."""
|
"""Test if we have a type mismatch for packages."""
|
||||||
packages = {
|
packages = {
|
||||||
"pack_1": {"input_boolean": [{"ib1": None}]},
|
"pack_1": {"input_boolean": [{"ib1": None}]},
|
||||||
|
@ -1196,7 +1201,9 @@ async def test_merge_type_mismatch(merge_log_err, hass: HomeAssistant) -> None:
|
||||||
assert len(config["light"]) == 2
|
assert len(config["light"]) == 2
|
||||||
|
|
||||||
|
|
||||||
async def test_merge_once_only_keys(merge_log_err, hass: HomeAssistant) -> None:
|
async def test_merge_once_only_keys(
|
||||||
|
merge_log_err: MagicMock, hass: HomeAssistant
|
||||||
|
) -> None:
|
||||||
"""Test if we have a merge for a comp that may occur only once. Keys."""
|
"""Test if we have a merge for a comp that may occur only once. Keys."""
|
||||||
packages = {"pack_2": {"api": None}}
|
packages = {"pack_2": {"api": None}}
|
||||||
config = {HA_DOMAIN: {config_util.CONF_PACKAGES: packages}, "api": None}
|
config = {HA_DOMAIN: {config_util.CONF_PACKAGES: packages}, "api": None}
|
||||||
|
@ -1282,7 +1289,9 @@ async def test_merge_id_schema(hass: HomeAssistant) -> None:
|
||||||
assert typ == expected_type, f"{domain} expected {expected_type}, got {typ}"
|
assert typ == expected_type, f"{domain} expected {expected_type}, got {typ}"
|
||||||
|
|
||||||
|
|
||||||
async def test_merge_duplicate_keys(merge_log_err, hass: HomeAssistant) -> None:
|
async def test_merge_duplicate_keys(
|
||||||
|
merge_log_err: MagicMock, hass: HomeAssistant
|
||||||
|
) -> None:
|
||||||
"""Test if keys in dicts are duplicates."""
|
"""Test if keys in dicts are duplicates."""
|
||||||
packages = {"pack_1": {"input_select": {"ib1": None}}}
|
packages = {"pack_1": {"input_select": {"ib1": None}}}
|
||||||
config = {
|
config = {
|
||||||
|
|
|
@ -3094,14 +3094,14 @@ async def test_get_release_channel(
|
||||||
assert get_release_channel() == release_channel
|
assert get_release_channel() == release_channel
|
||||||
|
|
||||||
|
|
||||||
def test_is_callback_check_partial():
|
def test_is_callback_check_partial() -> None:
|
||||||
"""Test is_callback_check_partial matches HassJob."""
|
"""Test is_callback_check_partial matches HassJob."""
|
||||||
|
|
||||||
@ha.callback
|
@ha.callback
|
||||||
def callback_func():
|
def callback_func() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def not_callback_func():
|
def not_callback_func() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
assert ha.is_callback(callback_func)
|
assert ha.is_callback(callback_func)
|
||||||
|
@ -3130,14 +3130,14 @@ def test_is_callback_check_partial():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_hassjob_passing_job_type():
|
def test_hassjob_passing_job_type() -> None:
|
||||||
"""Test passing the job type to HassJob when we already know it."""
|
"""Test passing the job type to HassJob when we already know it."""
|
||||||
|
|
||||||
@ha.callback
|
@ha.callback
|
||||||
def callback_func():
|
def callback_func() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def not_callback_func():
|
def not_callback_func() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
|
@ -3237,7 +3237,7 @@ async def test_async_run_job_deprecated(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test async_run_job warns about its deprecation."""
|
"""Test async_run_job warns about its deprecation."""
|
||||||
|
|
||||||
async def _test():
|
async def _test() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
hass.async_run_job(_test)
|
hass.async_run_job(_test)
|
||||||
|
@ -3254,7 +3254,7 @@ async def test_async_add_job_deprecated(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test async_add_job warns about its deprecation."""
|
"""Test async_add_job warns about its deprecation."""
|
||||||
|
|
||||||
async def _test():
|
async def _test() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
hass.async_add_job(_test)
|
hass.async_add_job(_test)
|
||||||
|
@ -3271,7 +3271,7 @@ async def test_async_add_hass_job_deprecated(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test async_add_hass_job warns about its deprecation."""
|
"""Test async_add_hass_job warns about its deprecation."""
|
||||||
|
|
||||||
async def _test():
|
async def _test() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
hass.async_add_hass_job(HassJob(_test))
|
hass.async_add_hass_job(HassJob(_test))
|
||||||
|
|
Loading…
Reference in New Issue