mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
committed by
GitHub
parent
27219b6962
commit
6bb4e7d62c
@@ -91,12 +91,15 @@ async def test_load_with_supervisor_diagnostics(hass: HomeAssistant) -> None:
|
||||
"""Test loading with a supervisor that has diagnostics enabled."""
|
||||
analytics = Analytics(hass)
|
||||
assert not analytics.preferences[ATTR_DIAGNOSTICS]
|
||||
with patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(return_value={"diagnostics": True}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(return_value={"diagnostics": True}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
),
|
||||
):
|
||||
await analytics.load()
|
||||
assert analytics.preferences[ATTR_DIAGNOSTICS]
|
||||
@@ -109,12 +112,15 @@ async def test_load_with_supervisor_without_diagnostics(hass: HomeAssistant) ->
|
||||
|
||||
assert analytics.preferences[ATTR_DIAGNOSTICS]
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(return_value={"diagnostics": False}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(return_value={"diagnostics": False}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
),
|
||||
):
|
||||
await analytics.load()
|
||||
|
||||
@@ -190,23 +196,29 @@ async def test_send_base_with_supervisor(
|
||||
await analytics.save_preferences({ATTR_BASE: True})
|
||||
assert analytics.preferences[ATTR_BASE]
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(
|
||||
return_value={"supported": True, "healthy": True, "arch": "amd64"}
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(
|
||||
return_value={"supported": True, "healthy": True, "arch": "amd64"}
|
||||
),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_os_info",
|
||||
side_effect=Mock(return_value={"board": "blue", "version": "123"}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_host_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.get_os_info",
|
||||
side_effect=Mock(return_value={"board": "blue", "version": "123"}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.get_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.get_host_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
):
|
||||
await analytics.load()
|
||||
|
||||
@@ -270,38 +282,45 @@ async def test_send_usage_with_supervisor(
|
||||
assert analytics.preferences[ATTR_USAGE]
|
||||
hass.config.components = ["default_config"]
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(
|
||||
return_value={
|
||||
"healthy": True,
|
||||
"supported": True,
|
||||
"arch": "amd64",
|
||||
"addons": [{"slug": "test_addon"}],
|
||||
}
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(
|
||||
return_value={
|
||||
"healthy": True,
|
||||
"supported": True,
|
||||
"arch": "amd64",
|
||||
"addons": [{"slug": "test_addon"}],
|
||||
}
|
||||
),
|
||||
),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.get_os_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.get_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.get_host_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.async_get_addon_info",
|
||||
side_effect=AsyncMock(
|
||||
return_value={
|
||||
"slug": "test_addon",
|
||||
"protected": True,
|
||||
"version": "1",
|
||||
"auto_update": False,
|
||||
}
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_os_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_host_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.async_get_addon_info",
|
||||
side_effect=AsyncMock(
|
||||
return_value={
|
||||
"slug": "test_addon",
|
||||
"protected": True,
|
||||
"version": "1",
|
||||
"auto_update": False,
|
||||
}
|
||||
),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
):
|
||||
await analytics.send_analytics()
|
||||
|
||||
@@ -461,9 +480,12 @@ async def test_send_statistics_async_get_integration_unknown_exception(
|
||||
assert analytics.preferences[ATTR_STATISTICS]
|
||||
hass.config.components = ["default_config"]
|
||||
|
||||
with pytest.raises(ValueError), patch(
|
||||
"homeassistant.components.analytics.analytics.async_get_integrations",
|
||||
return_value={"any": ValueError()},
|
||||
with (
|
||||
pytest.raises(ValueError),
|
||||
patch(
|
||||
"homeassistant.components.analytics.analytics.async_get_integrations",
|
||||
return_value={"any": ValueError()},
|
||||
),
|
||||
):
|
||||
await analytics.send_analytics()
|
||||
|
||||
@@ -482,38 +504,45 @@ async def test_send_statistics_with_supervisor(
|
||||
assert analytics.preferences[ATTR_BASE]
|
||||
assert analytics.preferences[ATTR_STATISTICS]
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(
|
||||
return_value={
|
||||
"healthy": True,
|
||||
"supported": True,
|
||||
"arch": "amd64",
|
||||
"addons": [{"slug": "test_addon"}],
|
||||
}
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_supervisor_info",
|
||||
side_effect=Mock(
|
||||
return_value={
|
||||
"healthy": True,
|
||||
"supported": True,
|
||||
"arch": "amd64",
|
||||
"addons": [{"slug": "test_addon"}],
|
||||
}
|
||||
),
|
||||
),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.get_os_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.get_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.get_host_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.async_get_addon_info",
|
||||
side_effect=AsyncMock(
|
||||
return_value={
|
||||
"slug": "test_addon",
|
||||
"protected": True,
|
||||
"version": "1",
|
||||
"auto_update": False,
|
||||
}
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_os_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.get_host_info",
|
||||
side_effect=Mock(return_value={}),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.async_get_addon_info",
|
||||
side_effect=AsyncMock(
|
||||
return_value={
|
||||
"slug": "test_addon",
|
||||
"protected": True,
|
||||
"version": "1",
|
||||
"auto_update": False,
|
||||
}
|
||||
),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
),
|
||||
), patch(
|
||||
"homeassistant.components.hassio.is_hassio",
|
||||
side_effect=Mock(return_value=True),
|
||||
):
|
||||
await analytics.send_analytics()
|
||||
|
||||
@@ -641,12 +670,16 @@ async def test_send_with_no_energy(
|
||||
|
||||
await analytics.save_preferences({ATTR_BASE: True, ATTR_USAGE: True})
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.analytics.analytics.energy_is_configured", AsyncMock()
|
||||
) as energy_is_configured, patch(
|
||||
"homeassistant.components.analytics.analytics.get_recorder_instance",
|
||||
Mock(),
|
||||
) as get_recorder_instance:
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.analytics.analytics.energy_is_configured",
|
||||
AsyncMock(),
|
||||
) as energy_is_configured,
|
||||
patch(
|
||||
"homeassistant.components.analytics.analytics.get_recorder_instance",
|
||||
Mock(),
|
||||
) as get_recorder_instance,
|
||||
):
|
||||
energy_is_configured.return_value = False
|
||||
get_recorder_instance.return_value = Mock(database_engine=Mock())
|
||||
await analytics.send_analytics()
|
||||
@@ -849,21 +882,24 @@ async def test_not_check_config_entries_if_yaml(
|
||||
)
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.analytics.analytics.async_get_integrations",
|
||||
return_value={
|
||||
"default_config": mock_integration(
|
||||
hass,
|
||||
MockModule(
|
||||
"default_config",
|
||||
async_setup=AsyncMock(return_value=True),
|
||||
partial_manifest={"config_flow": True},
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.analytics.analytics.async_get_integrations",
|
||||
return_value={
|
||||
"default_config": mock_integration(
|
||||
hass,
|
||||
MockModule(
|
||||
"default_config",
|
||||
async_setup=AsyncMock(return_value=True),
|
||||
partial_manifest={"config_flow": True},
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
), patch(
|
||||
"homeassistant.config.load_yaml_config_file",
|
||||
return_value={"default_config": {}},
|
||||
},
|
||||
),
|
||||
patch(
|
||||
"homeassistant.config.load_yaml_config_file",
|
||||
return_value={"default_config": {}},
|
||||
),
|
||||
):
|
||||
await analytics.send_analytics()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user