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