Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename some check_config test cases #104244

Merged
merged 1 commit into from Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 22 additions & 22 deletions tests/helpers/test_check_config.py
Expand Up @@ -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):
Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -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):
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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"}
Expand All @@ -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(
Expand Down