Rename some check_config test cases (#104244)

This commit is contained in:
Erik Montnemery 2023-11-20 13:02:44 +01:00 committed by GitHub
parent 2def7d2e71
commit a573f60947
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,8 +103,8 @@ async def test_config_platform_valid(hass: HomeAssistant) -> None:
_assert_warnings_errors(res, [], [])
async def test_component_platform_not_found(hass: HomeAssistant) -> None:
"""Test errors if component or platform not found."""
async def test_integration_not_found(hass: HomeAssistant) -> None:
"""Test errors if integration not found."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "beer:"}
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
@ -118,8 +118,8 @@ async def test_component_platform_not_found(hass: HomeAssistant) -> None:
_assert_warnings_errors(res, [warning], [])
async def test_component_requirement_not_found(hass: HomeAssistant) -> None:
"""Test errors if component with a requirement not found not found."""
async def test_integrationt_requirement_not_found(hass: HomeAssistant) -> None:
"""Test errors if integration with a requirement not found not found."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "test_custom_component:"}
with patch(
@ -141,8 +141,8 @@ async def test_component_requirement_not_found(hass: HomeAssistant) -> None:
_assert_warnings_errors(res, [warning], [])
async def test_component_not_found_recovery_mode(hass: HomeAssistant) -> None:
"""Test no errors if component not found in recovery mode."""
async def test_integration_not_found_recovery_mode(hass: HomeAssistant) -> None:
"""Test no errors if integration not found in recovery mode."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "beer:"}
hass.config.recovery_mode = True
@ -154,8 +154,8 @@ async def test_component_not_found_recovery_mode(hass: HomeAssistant) -> None:
_assert_warnings_errors(res, [], [])
async def test_component_not_found_safe_mode(hass: HomeAssistant) -> None:
"""Test no errors if component not found in safe mode."""
async def test_integration_not_found_safe_mode(hass: HomeAssistant) -> None:
"""Test no errors if integration not found in safe mode."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "beer:"}
hass.config.safe_mode = True
@ -167,8 +167,8 @@ async def test_component_not_found_safe_mode(hass: HomeAssistant) -> None:
_assert_warnings_errors(res, [], [])
async def test_component_import_error(hass: HomeAssistant) -> None:
"""Test errors if component with a requirement not found not found."""
async def test_integration_import_error(hass: HomeAssistant) -> None:
"""Test errors if integration with a requirement not found not found."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:"}
with patch(
@ -188,19 +188,19 @@ async def test_component_import_error(hass: HomeAssistant) -> None:
@pytest.mark.parametrize(
("component", "errors", "warnings", "message"),
("integration", "errors", "warnings", "message"),
[
("frontend", 1, 0, "'blah' is an invalid option for 'frontend'"),
("http", 1, 0, "'blah' is an invalid option for 'http'"),
("logger", 0, 1, "'blah' is an invalid option for 'logger'"),
],
)
async def test_component_schema_error(
hass: HomeAssistant, component: str, errors: int, warnings: int, message: str
async def test_integration_schema_error(
hass: HomeAssistant, integration: str, errors: int, warnings: int, message: str
) -> None:
"""Test schema error in component."""
"""Test schema error in integration."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + f"frontend:\n{component}:\n blah:"}
files = {YAML_CONFIG_FILE: BASE_CONFIG + f"frontend:\n{integration}:\n blah:"}
hass.config.safe_mode = True
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await async_check_ha_config_file(hass)
@ -215,8 +215,8 @@ async def test_component_schema_error(
assert message in warn.message
async def test_component_platform_not_found_2(hass: HomeAssistant) -> None:
"""Test errors if component or platform not found."""
async def test_platform_not_found(hass: HomeAssistant) -> None:
"""Test errors if platform not found."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"}
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
@ -293,14 +293,14 @@ async def test_platform_not_found_safe_mode(hass: HomeAssistant) -> None:
),
],
)
async def test_component_platform_schema_error(
async def test_platform_schema_error(
hass: HomeAssistant,
extra_config: str,
warnings: int,
message: str | None,
config: dict | None,
) -> None:
"""Test schema error in component."""
"""Test schema error in platform."""
comp_platform_schema = cv.PLATFORM_SCHEMA.extend({vol.Remove("old"): str})
comp_platform_schema_base = comp_platform_schema.extend({}, extra=vol.ALLOW_EXTRA)
mock_integration(
@ -328,7 +328,7 @@ async def test_component_platform_schema_error(
assert warn.config == config
async def test_component_config_platform_import_error(hass: HomeAssistant) -> None:
async def test_config_platform_import_error(hass: HomeAssistant) -> None:
"""Test errors if config platform fails to import."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"}
@ -348,8 +348,8 @@ async def test_component_config_platform_import_error(hass: HomeAssistant) -> No
_assert_warnings_errors(res, [], [error])
async def test_component_platform_import_error(hass: HomeAssistant) -> None:
"""Test errors if component or platform not found."""
async def test_platform_import_error(hass: HomeAssistant) -> None:
"""Test errors if platform not found."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: demo"}
with patch(