mirror of
https://github.com/home-assistant/core.git
synced 2026-02-15 07:36:16 +00:00
Reformat lambda (tests) (#162383)
This commit is contained in:
@@ -141,10 +141,12 @@ def mock_backup_generation_fixture(
|
||||
patch("pathlib.Path.is_dir", lambda x: x in CONFIG_DIR_DIRS),
|
||||
patch(
|
||||
"pathlib.Path.exists",
|
||||
lambda x: x
|
||||
not in (
|
||||
Path(hass.config.path("backups")),
|
||||
Path(hass.config.path("tmp_backups")),
|
||||
lambda x: (
|
||||
x
|
||||
not in (
|
||||
Path(hass.config.path("backups")),
|
||||
Path(hass.config.path("tmp_backups")),
|
||||
)
|
||||
),
|
||||
),
|
||||
patch(
|
||||
|
||||
@@ -2192,9 +2192,11 @@ async def test_download_support_package_integration_load_error(
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.cloud.http_api.async_get_loaded_integration",
|
||||
side_effect=lambda hass, domain: Exception("Integration load error")
|
||||
if domain == "failing_integration"
|
||||
else async_get_loaded_integration(hass, domain),
|
||||
side_effect=lambda hass, domain: (
|
||||
Exception("Integration load error")
|
||||
if domain == "failing_integration"
|
||||
else async_get_loaded_integration(hass, domain)
|
||||
),
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.cloud.http_api.async_get_installed_packages",
|
||||
|
||||
@@ -45,8 +45,8 @@ async def test_select_unknown_device_parameters(
|
||||
mock_return_value: Any,
|
||||
) -> None:
|
||||
"""Test that select entity shows unknown when get_current_option returns various invalid values."""
|
||||
mock_connector.get_current_option.side_effect = (
|
||||
lambda device_id, parameter_code: mock_return_value
|
||||
mock_connector.get_current_option.side_effect = lambda device_id, parameter_code: (
|
||||
mock_return_value
|
||||
)
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
|
||||
@@ -72,9 +72,11 @@ def mock_router(mock_device_registry_devices):
|
||||
# device_tracker
|
||||
instance.lan.get_interfaces = AsyncMock(return_value=DATA_LAN_GET_INTERFACES)
|
||||
instance.lan.get_hosts_list = AsyncMock(
|
||||
side_effect=lambda interface: DATA_LAN_GET_HOSTS_LIST
|
||||
if interface == "pub"
|
||||
else DATA_LAN_GET_HOSTS_LIST_GUEST
|
||||
side_effect=lambda interface: (
|
||||
DATA_LAN_GET_HOSTS_LIST
|
||||
if interface == "pub"
|
||||
else DATA_LAN_GET_HOSTS_LIST_GUEST
|
||||
)
|
||||
)
|
||||
# sensor
|
||||
instance.call.get_calls_log = AsyncMock(return_value=DATA_CALL_GET_CALLS_LOG)
|
||||
|
||||
@@ -31,8 +31,8 @@ def build_mock_node(file: str) -> AsyncMock:
|
||||
for key, value in attribute.items():
|
||||
setattr(att, key, value)
|
||||
att.is_reversed = False
|
||||
att.get_value = (
|
||||
lambda att=att: att.data if att.unit == "text" else att.current_value
|
||||
att.get_value = lambda att=att: (
|
||||
att.data if att.unit == "text" else att.current_value
|
||||
)
|
||||
mock_attributes.append(att)
|
||||
return mock_attributes
|
||||
|
||||
@@ -84,8 +84,8 @@ async def test_general_data(
|
||||
build_mock_node("cover_with_position_slats.json"),
|
||||
build_mock_node("homee.json"),
|
||||
]
|
||||
mock_homee.get_node_by_id = (
|
||||
lambda node_id: mock_homee.nodes[0] if node_id == 3 else mock_homee.nodes[1]
|
||||
mock_homee.get_node_by_id = lambda node_id: (
|
||||
mock_homee.nodes[0] if node_id == 3 else mock_homee.nodes[1]
|
||||
)
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
|
||||
@@ -153,8 +153,8 @@ def mock_device_client() -> Generator[AsyncMock]:
|
||||
device_client.device_info.side_effect = lambda serial: _mock_device_info(
|
||||
serial[:5]
|
||||
)
|
||||
device_client.get_light_brightness_levels.side_effect = (
|
||||
lambda serial: _mock_light_brightness_levels(serial[:5])
|
||||
device_client.get_light_brightness_levels.side_effect = lambda serial: (
|
||||
_mock_light_brightness_levels(serial[:5])
|
||||
)
|
||||
device_client.get_current_status.side_effect = get_current_status_side_effect
|
||||
device_client.request_status_update.side_effect = request_status_side_effect
|
||||
|
||||
@@ -147,8 +147,8 @@ def _mocked_ring_device(device_dict, device_family, device_class, capabilities):
|
||||
mock_device.configure_mock(
|
||||
motion_detection=device_dict["settings"].get("motion_detection_enabled"),
|
||||
)
|
||||
mock_device.async_set_motion_detection.side_effect = (
|
||||
lambda i: mock_device.configure_mock(motion_detection=i)
|
||||
mock_device.async_set_motion_detection.side_effect = lambda i: (
|
||||
mock_device.configure_mock(motion_detection=i)
|
||||
)
|
||||
|
||||
if has_capability(RingCapability.LIGHT):
|
||||
@@ -190,8 +190,8 @@ def _mocked_ring_device(device_dict, device_family, device_class, capabilities):
|
||||
"chime_settings"
|
||||
].get("enable", False)
|
||||
)
|
||||
mock_device.async_set_existing_doorbell_type_enabled.side_effect = (
|
||||
lambda i: mock_device.configure_mock(existing_doorbell_type_enabled=i)
|
||||
mock_device.async_set_existing_doorbell_type_enabled.side_effect = lambda i: (
|
||||
mock_device.configure_mock(existing_doorbell_type_enabled=i)
|
||||
)
|
||||
|
||||
if device_family == "other":
|
||||
|
||||
@@ -65,8 +65,8 @@ def mock_russound_client() -> Generator[AsyncMock]:
|
||||
for zone_id, zone in zones.items():
|
||||
zone.device_str = zone_device_str(controller_id, zone_id)
|
||||
zone.fetch_current_source = Mock(
|
||||
side_effect=lambda current_source=zone.current_source: client.sources.get(
|
||||
int(current_source)
|
||||
side_effect=lambda current_source=zone.current_source: (
|
||||
client.sources.get(int(current_source))
|
||||
)
|
||||
)
|
||||
zone.volume_up = AsyncMock()
|
||||
|
||||
@@ -215,15 +215,14 @@ def _mocked_device(
|
||||
for mod in device.modules.values():
|
||||
# Some tests remove the feature from device_features to test missing
|
||||
# features, so check the key is still present there.
|
||||
mod.get_feature.side_effect = (
|
||||
lambda mod_id: mod_feat
|
||||
mod.get_feature.side_effect = lambda mod_id: (
|
||||
mod_feat
|
||||
if (mod_feat := module_features.get(mod_id))
|
||||
and mod_feat.id in device_features
|
||||
else None
|
||||
)
|
||||
mod.has_feature.side_effect = (
|
||||
lambda mod_id: (mod_feat := module_features.get(mod_id))
|
||||
and mod_feat.id in device_features
|
||||
mod.has_feature.side_effect = lambda mod_id: (
|
||||
(mod_feat := module_features.get(mod_id)) and mod_feat.id in device_features
|
||||
)
|
||||
|
||||
device.parent = None
|
||||
|
||||
@@ -177,8 +177,8 @@ def mock_oven_single_cavity_api():
|
||||
mock_oven.get_cavity_state.return_value = oven.CavityState.Standby
|
||||
mock_oven.get_cook_mode.return_value = oven.CookMode.Bake
|
||||
mock_oven.get_online.return_value = True
|
||||
mock_oven.get_oven_cavity_exists.side_effect = (
|
||||
lambda cavity: cavity == oven.Cavity.Upper
|
||||
mock_oven.get_oven_cavity_exists.side_effect = lambda cavity: (
|
||||
cavity == oven.Cavity.Upper
|
||||
)
|
||||
mock_oven.get_temp.return_value = 180
|
||||
mock_oven.get_target_temp.return_value = 200
|
||||
@@ -196,9 +196,12 @@ def mock_oven_dual_cavity_api():
|
||||
mock_oven.get_cavity_state.return_value = oven.CavityState.Standby
|
||||
mock_oven.get_cook_mode.return_value = oven.CookMode.Bake
|
||||
mock_oven.get_online.return_value = True
|
||||
mock_oven.get_oven_cavity_exists.side_effect = lambda cavity: cavity in (
|
||||
oven.Cavity.Upper,
|
||||
oven.Cavity.Lower,
|
||||
mock_oven.get_oven_cavity_exists.side_effect = lambda cavity: (
|
||||
cavity
|
||||
in (
|
||||
oven.Cavity.Upper,
|
||||
oven.Cavity.Lower,
|
||||
)
|
||||
)
|
||||
mock_oven.get_temp.return_value = 180
|
||||
mock_oven.get_target_temp.return_value = 200
|
||||
|
||||
Reference in New Issue
Block a user