Remove default args to ESPHome test fixture calls (#145840)

This commit is contained in:
J. Nick Koston 2025-05-29 01:45:37 -05:00 committed by GitHub
parent 55e664fc0d
commit 23ac22e213
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 12 additions and 252 deletions

View File

@ -54,9 +54,9 @@ class MockGenericDeviceEntryType(Protocol):
async def __call__( async def __call__(
self, self,
mock_client: APIClient, mock_client: APIClient,
entity_info: list[EntityInfo], entity_info: list[EntityInfo] | None = ...,
user_service: list[UserService], user_service: list[UserService] | None = ...,
states: list[EntityState], states: list[EntityState] | None = ...,
mock_storage: bool = ..., mock_storage: bool = ...,
) -> MockConfigEntry: ) -> MockConfigEntry:
"""Mock an ESPHome device entry.""" """Mock an ESPHome device entry."""
@ -685,9 +685,9 @@ async def mock_generic_device_entry(
async def _mock_device_entry( async def _mock_device_entry(
mock_client: APIClient, mock_client: APIClient,
entity_info: list[EntityInfo], entity_info: list[EntityInfo] | None = None,
user_service: list[UserService], user_service: list[UserService] | None = None,
states: list[EntityState], states: list[EntityState] | None = None,
mock_storage: bool = False, mock_storage: bool = False,
) -> MockConfigEntry: ) -> MockConfigEntry:
return ( return (
@ -695,8 +695,8 @@ async def mock_generic_device_entry(
hass, hass,
mock_client, mock_client,
{}, {},
(entity_info, user_service), (entity_info or [], user_service or []),
states, states or [],
None, None,
hass_storage if mock_storage else None, hass_storage if mock_storage else None,
) )

View File

@ -73,9 +73,6 @@ async def test_no_satellite_without_voice_assistant(
"""Test that an assist satellite entity is not created if a voice assistant is not present.""" """Test that an assist satellite entity is not created if a voice assistant is not present."""
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={}, device_info={},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -96,9 +93,6 @@ async def test_pipeline_api_audio(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.SPEAKER | VoiceAssistantFeature.SPEAKER
@ -406,9 +400,6 @@ async def test_pipeline_udp_audio(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.SPEAKER | VoiceAssistantFeature.SPEAKER
@ -616,9 +607,6 @@ async def test_pipeline_media_player(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.API_AUDIO | VoiceAssistantFeature.API_AUDIO
@ -762,9 +750,6 @@ async def test_timer_events(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.TIMERS | VoiceAssistantFeature.TIMERS
@ -833,9 +818,6 @@ async def test_unknown_timer_event(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.TIMERS | VoiceAssistantFeature.TIMERS
@ -877,9 +859,6 @@ async def test_streaming_tts_errors(
"""Test error conditions for _stream_tts_audio function.""" """Test error conditions for _stream_tts_audio function."""
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
}, },
@ -1089,9 +1068,6 @@ async def test_announce_message(
"""Test announcement with message.""" """Test announcement with message."""
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.SPEAKER | VoiceAssistantFeature.SPEAKER
@ -1260,9 +1236,6 @@ async def test_announce_message_with_preannounce(
"""Test announcement with message and preannounce media id.""" """Test announcement with message and preannounce media id."""
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.SPEAKER | VoiceAssistantFeature.SPEAKER
@ -1334,9 +1307,6 @@ async def test_non_default_supported_features(
"""Test that the start conversation and announce are not set by default.""" """Test that the start conversation and announce are not set by default."""
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
}, },
@ -1360,9 +1330,6 @@ async def test_start_conversation_message(
"""Test start conversation with message.""" """Test start conversation with message."""
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.SPEAKER | VoiceAssistantFeature.SPEAKER
@ -1569,9 +1536,6 @@ async def test_start_conversation_message_with_preannounce(
"""Test start conversation with message and preannounce media id.""" """Test start conversation with message and preannounce media id."""
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.SPEAKER | VoiceAssistantFeature.SPEAKER
@ -1662,9 +1626,6 @@ async def test_satellite_unloaded_on_disconnect(
"""Test that the assist satellite platform is unloaded on disconnect.""" """Test that the assist satellite platform is unloaded on disconnect."""
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
}, },
@ -1694,9 +1655,6 @@ async def test_pipeline_abort(
"""Test aborting a pipeline (no further processing).""" """Test aborting a pipeline (no further processing)."""
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.API_AUDIO | VoiceAssistantFeature.API_AUDIO
@ -1778,9 +1736,6 @@ async def test_get_set_configuration(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.ANNOUNCE | VoiceAssistantFeature.ANNOUNCE
@ -1839,9 +1794,6 @@ async def test_wake_word_select(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.ANNOUNCE | VoiceAssistantFeature.ANNOUNCE

View File

@ -1722,9 +1722,6 @@ async def test_option_flow_allow_service_calls(
"""Test config flow options for allow service calls.""" """Test config flow options for allow service calls."""
entry = await mock_generic_device_entry( entry = await mock_generic_device_entry(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
@ -1767,9 +1764,6 @@ async def test_option_flow_subscribe_logs(
"""Test config flow options with subscribe logs.""" """Test config flow options with subscribe logs."""
entry = await mock_generic_device_entry( entry = await mock_generic_device_entry(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)

View File

@ -52,9 +52,6 @@ async def test_diagnostics_with_dashboard_data(
) )
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
await MockDashboardRefresh(hass).async_refresh() await MockDashboardRefresh(hass).async_refresh()
result = await get_diagnostics_for_config_entry( result = await get_diagnostics_for_config_entry(

View File

@ -59,11 +59,9 @@ async def test_entities_removed(
BinarySensorState(key=1, state=True, missing_state=False), BinarySensorState(key=1, state=True, missing_state=False),
BinarySensorState(key=2, state=True, missing_state=False), BinarySensorState(key=2, state=True, missing_state=False),
] ]
user_service = []
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
) )
entry = mock_device.entry entry = mock_device.entry
@ -106,7 +104,6 @@ async def test_entities_removed(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
entry=entry, entry=entry,
) )
@ -151,11 +148,9 @@ async def test_entities_removed_after_reload(
BinarySensorState(key=1, state=True, missing_state=False), BinarySensorState(key=1, state=True, missing_state=False),
BinarySensorState(key=2, state=True, missing_state=False), BinarySensorState(key=2, state=True, missing_state=False),
] ]
user_service = []
mock_device: MockESPHomeDevice = await mock_esphome_device( mock_device: MockESPHomeDevice = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
) )
entry = mock_device.entry entry = mock_device.entry
@ -218,7 +213,7 @@ async def test_entities_removed_after_reload(
), ),
] ]
mock_device.client.list_entities_services = AsyncMock( mock_device.client.list_entities_services = AsyncMock(
return_value=(entity_info, user_service) return_value=(entity_info, [])
) )
assert await hass.config_entries.async_setup(entry.entry_id) assert await hass.config_entries.async_setup(entry.entry_id)
@ -273,11 +268,9 @@ async def test_entities_for_entire_platform_removed(
states = [ states = [
BinarySensorState(key=1, state=True, missing_state=False), BinarySensorState(key=1, state=True, missing_state=False),
] ]
user_service = []
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
) )
entry = mock_device.entry entry = mock_device.entry
@ -300,13 +293,8 @@ async def test_entities_for_entire_platform_removed(
assert reg_entry is not None assert reg_entry is not None
assert state.attributes[ATTR_RESTORED] is True assert state.attributes[ATTR_RESTORED] is True
entity_info = []
states = []
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=user_service,
states=states,
entry=entry, entry=entry,
) )
assert mock_device.entry.entry_id == entry_id assert mock_device.entry.entry_id == entry_id
@ -336,11 +324,9 @@ async def test_entity_info_object_ids(
) )
] ]
states = [] states = []
user_service = []
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
) )
state = hass.states.get("binary_sensor.test_object_id_is_used") state = hass.states.get("binary_sensor.test_object_id_is_used")
@ -373,11 +359,9 @@ async def test_deep_sleep_device(
BinarySensorState(key=2, state=True, missing_state=False), BinarySensorState(key=2, state=True, missing_state=False),
SensorState(key=3, state=123.0, missing_state=False), SensorState(key=3, state=123.0, missing_state=False),
] ]
user_service = []
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
device_info={"has_deep_sleep": True}, device_info={"has_deep_sleep": True},
) )
@ -474,11 +458,9 @@ async def test_esphome_device_without_friendly_name(
BinarySensorState(key=1, state=True, missing_state=False), BinarySensorState(key=1, state=True, missing_state=False),
BinarySensorState(key=2, state=True, missing_state=False), BinarySensorState(key=2, state=True, missing_state=False),
] ]
user_service = []
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
device_info={"friendly_name": None}, device_info={"friendly_name": None},
) )
@ -505,11 +487,9 @@ async def test_entity_without_name_device_with_friendly_name(
states = [ states = [
BinarySensorState(key=1, state=True, missing_state=False), BinarySensorState(key=1, state=True, missing_state=False),
] ]
user_service = []
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
device_info={"friendly_name": "The Best Mixer", "name": "mixer"}, device_info={"friendly_name": "The Best Mixer", "name": "mixer"},
) )
@ -540,7 +520,6 @@ async def test_entity_id_preserved_on_upgrade(
states = [ states = [
BinarySensorState(key=1, state=True, missing_state=False), BinarySensorState(key=1, state=True, missing_state=False),
] ]
user_service = []
assert ( assert (
build_unique_id("11:22:33:44:55:AA", entity_info[0]) build_unique_id("11:22:33:44:55:AA", entity_info[0])
== "11:22:33:44:55:AA-binary_sensor-my" == "11:22:33:44:55:AA-binary_sensor-my"
@ -556,7 +535,6 @@ async def test_entity_id_preserved_on_upgrade(
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
device_info={"friendly_name": "The Best Mixer", "name": "mixer"}, device_info={"friendly_name": "The Best Mixer", "name": "mixer"},
) )
@ -583,7 +561,6 @@ async def test_entity_id_preserved_on_upgrade_old_format_entity_id(
states = [ states = [
BinarySensorState(key=1, state=True, missing_state=False), BinarySensorState(key=1, state=True, missing_state=False),
] ]
user_service = []
assert ( assert (
build_unique_id("11:22:33:44:55:AA", entity_info[0]) build_unique_id("11:22:33:44:55:AA", entity_info[0])
== "11:22:33:44:55:AA-binary_sensor-my" == "11:22:33:44:55:AA-binary_sensor-my"
@ -599,7 +576,6 @@ async def test_entity_id_preserved_on_upgrade_old_format_entity_id(
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
device_info={"name": "mixer"}, device_info={"name": "mixer"},
) )
@ -626,11 +602,9 @@ async def test_entity_id_preserved_on_upgrade_when_in_storage(
states = [ states = [
BinarySensorState(key=1, state=True, missing_state=False), BinarySensorState(key=1, state=True, missing_state=False),
] ]
user_service = []
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
device_info={"friendly_name": "The Best Mixer", "name": "mixer"}, device_info={"friendly_name": "The Best Mixer", "name": "mixer"},
) )
@ -660,7 +634,6 @@ async def test_entity_id_preserved_on_upgrade_when_in_storage(
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
entry=entry, entry=entry,
device_info={"friendly_name": "The Best Mixer", "name": "mixer"}, device_info={"friendly_name": "The Best Mixer", "name": "mixer"},
@ -685,7 +658,6 @@ async def test_deep_sleep_added_after_setup(
unique_id="test", unique_id="test",
), ),
], ],
user_service=[],
states=[ states=[
BinarySensorState(key=1, state=True, missing_state=False), BinarySensorState(key=1, state=True, missing_state=False),
], ],

View File

@ -80,10 +80,7 @@ async def test_esphome_device_subscribe_logs(
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entry=entry, entry=entry,
entity_info=[],
user_service=[],
device_info={}, device_info={},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -141,14 +138,8 @@ async def test_esphome_device_service_calls_not_allowed(
issue_registry: ir.IssueRegistry, issue_registry: ir.IssueRegistry,
) -> None: ) -> None:
"""Test a device with service calls not allowed.""" """Test a device with service calls not allowed."""
entity_info = []
states = []
user_service = []
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=user_service,
states=states,
device_info={"esphome_version": "2023.3.0"}, device_info={"esphome_version": "2023.3.0"},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -182,17 +173,11 @@ async def test_esphome_device_service_calls_allowed(
) -> None: ) -> None:
"""Test a device with service calls are allowed.""" """Test a device with service calls are allowed."""
await async_setup_component(hass, TAG_DOMAIN, {}) await async_setup_component(hass, TAG_DOMAIN, {})
entity_info = []
states = []
user_service = []
hass.config_entries.async_update_entry( hass.config_entries.async_update_entry(
mock_config_entry, options={CONF_ALLOW_SERVICE_CALLS: True} mock_config_entry, options={CONF_ALLOW_SERVICE_CALLS: True}
) )
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=user_service,
states=states,
device_info={"esphome_version": "2023.3.0"}, device_info={"esphome_version": "2023.3.0"},
entry=mock_config_entry, entry=mock_config_entry,
) )
@ -337,14 +322,8 @@ async def test_esphome_device_with_old_bluetooth(
issue_registry: ir.IssueRegistry, issue_registry: ir.IssueRegistry,
) -> None: ) -> None:
"""Test a device with old bluetooth creates an issue.""" """Test a device with old bluetooth creates an issue."""
entity_info = []
states = []
user_service = []
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=user_service,
states=states,
device_info={"bluetooth_proxy_feature_flags": 1, "esphome_version": "2023.3.0"}, device_info={"bluetooth_proxy_feature_flags": 1, "esphome_version": "2023.3.0"},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -364,10 +343,6 @@ async def test_esphome_device_with_password(
issue_registry: ir.IssueRegistry, issue_registry: ir.IssueRegistry,
) -> None: ) -> None:
"""Test a device with legacy password creates an issue.""" """Test a device with legacy password creates an issue."""
entity_info = []
states = []
user_service = []
entry = MockConfigEntry( entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
data={ data={
@ -379,9 +354,6 @@ async def test_esphome_device_with_password(
entry.add_to_hass(hass) entry.add_to_hass(hass)
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=user_service,
states=states,
device_info={"bluetooth_proxy_feature_flags": 0, "esphome_version": "2023.3.0"}, device_info={"bluetooth_proxy_feature_flags": 0, "esphome_version": "2023.3.0"},
entry=entry, entry=entry,
) )
@ -404,14 +376,8 @@ async def test_esphome_device_with_current_bluetooth(
issue_registry: ir.IssueRegistry, issue_registry: ir.IssueRegistry,
) -> None: ) -> None:
"""Test a device with recent bluetooth does not create an issue.""" """Test a device with recent bluetooth does not create an issue."""
entity_info = []
states = []
user_service = []
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=user_service,
states=states,
device_info={ device_info={
"bluetooth_proxy_feature_flags": 1, "bluetooth_proxy_feature_flags": 1,
"esphome_version": STABLE_BLE_VERSION_STR, "esphome_version": STABLE_BLE_VERSION_STR,
@ -857,9 +823,6 @@ async def test_state_subscription(
"""Test ESPHome subscribes to state changes.""" """Test ESPHome subscribes to state changes."""
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
hass.states.async_set("binary_sensor.test", "on", {"bool": True, "float": 3.0}) hass.states.async_set("binary_sensor.test", "on", {"bool": True, "float": 3.0})
@ -917,9 +880,6 @@ async def test_state_request(
"""Test ESPHome requests state change.""" """Test ESPHome requests state change."""
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
hass.states.async_set("binary_sensor.test", "on", {"bool": True, "float": 3.0}) hass.states.async_set("binary_sensor.test", "on", {"bool": True, "float": 3.0})
@ -944,9 +904,6 @@ async def test_debug_logging(
assert await async_setup_component(hass, "logger", {"logger": {}}) assert await async_setup_component(hass, "logger", {"logger": {}})
await mock_generic_device_entry( await mock_generic_device_entry(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
async with async_call_logger_set_level( async with async_call_logger_set_level(
"homeassistant.components.esphome", "DEBUG", hass=hass, caplog=caplog "homeassistant.components.esphome", "DEBUG", hass=hass, caplog=caplog
@ -966,8 +923,6 @@ async def test_esphome_device_with_dash_in_name_user_services(
mock_esphome_device: MockESPHomeDeviceType, mock_esphome_device: MockESPHomeDeviceType,
) -> None: ) -> None:
"""Test a device with user services and a dash in the name.""" """Test a device with user services and a dash in the name."""
entity_info = []
states = []
service1 = UserService( service1 = UserService(
name="my_service", name="my_service",
key=1, key=1,
@ -991,10 +946,8 @@ async def test_esphome_device_with_dash_in_name_user_services(
) )
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=[service1, service2], user_service=[service1, service2],
device_info={"name": "with-dash"}, device_info={"name": "with-dash"},
states=states,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert hass.services.has_service(DOMAIN, "with_dash_my_service") assert hass.services.has_service(DOMAIN, "with_dash_my_service")
@ -1018,9 +971,7 @@ async def test_esphome_device_with_dash_in_name_user_services(
mock_client.execute_service.reset_mock() mock_client.execute_service.reset_mock()
# Verify the service can be removed # Verify the service can be removed
mock_client.list_entities_services = AsyncMock( mock_client.list_entities_services = AsyncMock(return_value=([], [service1]))
return_value=(entity_info, [service1])
)
await device.mock_disconnect(True) await device.mock_disconnect(True)
await hass.async_block_till_done() await hass.async_block_till_done()
await device.mock_connect() await device.mock_connect()
@ -1035,8 +986,6 @@ async def test_esphome_user_services_ignores_invalid_arg_types(
mock_esphome_device: MockESPHomeDeviceType, mock_esphome_device: MockESPHomeDeviceType,
) -> None: ) -> None:
"""Test a device with user services and a dash in the name.""" """Test a device with user services and a dash in the name."""
entity_info = []
states = []
service1 = UserService( service1 = UserService(
name="bad_service", name="bad_service",
key=1, key=1,
@ -1053,10 +1002,8 @@ async def test_esphome_user_services_ignores_invalid_arg_types(
) )
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=[service1, service2], user_service=[service1, service2],
device_info={"name": "with-dash"}, device_info={"name": "with-dash"},
states=states,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert not hass.services.has_service(DOMAIN, "with_dash_bad_service") assert not hass.services.has_service(DOMAIN, "with_dash_bad_service")
@ -1080,9 +1027,7 @@ async def test_esphome_user_services_ignores_invalid_arg_types(
mock_client.execute_service.reset_mock() mock_client.execute_service.reset_mock()
# Verify the service can be removed # Verify the service can be removed
mock_client.list_entities_services = AsyncMock( mock_client.list_entities_services = AsyncMock(return_value=([], [service2]))
return_value=(entity_info, [service2])
)
await device.mock_disconnect(True) await device.mock_disconnect(True)
await hass.async_block_till_done() await hass.async_block_till_done()
await device.mock_connect() await device.mock_connect()
@ -1097,8 +1042,6 @@ async def test_esphome_user_service_fails(
mock_esphome_device: MockESPHomeDeviceType, mock_esphome_device: MockESPHomeDeviceType,
) -> None: ) -> None:
"""Test executing a user service fails due to disconnect.""" """Test executing a user service fails due to disconnect."""
entity_info = []
states = []
service1 = UserService( service1 = UserService(
name="simple_service", name="simple_service",
key=2, key=2,
@ -1108,10 +1051,8 @@ async def test_esphome_user_service_fails(
) )
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=[service1], user_service=[service1],
device_info={"name": "with-dash"}, device_info={"name": "with-dash"},
states=states,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert hass.services.has_service(DOMAIN, "with_dash_simple_service") assert hass.services.has_service(DOMAIN, "with_dash_simple_service")
@ -1153,8 +1094,6 @@ async def test_esphome_user_services_changes(
mock_esphome_device: MockESPHomeDeviceType, mock_esphome_device: MockESPHomeDeviceType,
) -> None: ) -> None:
"""Test a device with user services that change arguments.""" """Test a device with user services that change arguments."""
entity_info = []
states = []
service1 = UserService( service1 = UserService(
name="simple_service", name="simple_service",
key=2, key=2,
@ -1164,10 +1103,8 @@ async def test_esphome_user_services_changes(
) )
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=[service1], user_service=[service1],
device_info={"name": "with-dash"}, device_info={"name": "with-dash"},
states=states,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert hass.services.has_service(DOMAIN, "with_dash_simple_service") assert hass.services.has_service(DOMAIN, "with_dash_simple_service")
@ -1198,9 +1135,7 @@ async def test_esphome_user_services_changes(
) )
# Verify the service can be updated # Verify the service can be updated
mock_client.list_entities_services = AsyncMock( mock_client.list_entities_services = AsyncMock(return_value=([], [new_service1]))
return_value=(entity_info, [new_service1])
)
await device.mock_disconnect(True) await device.mock_disconnect(True)
await hass.async_block_till_done() await hass.async_block_till_done()
await device.mock_connect() await device.mock_connect()
@ -1234,10 +1169,7 @@ async def test_esphome_device_with_suggested_area(
"""Test a device with suggested area.""" """Test a device with suggested area."""
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
device_info={"suggested_area": "kitchen"}, device_info={"suggested_area": "kitchen"},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
entry = device.entry entry = device.entry
@ -1256,10 +1188,7 @@ async def test_esphome_device_with_project(
"""Test a device with a project.""" """Test a device with a project."""
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
device_info={"project_name": "mfr.model", "project_version": "2.2.2"}, device_info={"project_name": "mfr.model", "project_version": "2.2.2"},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
entry = device.entry entry = device.entry
@ -1280,10 +1209,7 @@ async def test_esphome_device_with_manufacturer(
"""Test a device with a manufacturer.""" """Test a device with a manufacturer."""
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
device_info={"manufacturer": "acme"}, device_info={"manufacturer": "acme"},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
entry = device.entry entry = device.entry
@ -1302,10 +1228,7 @@ async def test_esphome_device_with_web_server(
"""Test a device with a web server.""" """Test a device with a web server."""
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
device_info={"webserver_port": 80}, device_info={"webserver_port": 80},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
entry = device.entry entry = device.entry
@ -1335,10 +1258,7 @@ async def test_esphome_device_with_ipv6_web_server(
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entry=entry, entry=entry,
entity_info=[],
user_service=[],
device_info={"webserver_port": 80}, device_info={"webserver_port": 80},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
entry = device.entry entry = device.entry
@ -1357,10 +1277,7 @@ async def test_esphome_device_with_compilation_time(
"""Test a device with a compilation_time.""" """Test a device with a compilation_time."""
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
device_info={"compilation_time": "comp_time"}, device_info={"compilation_time": "comp_time"},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
entry = device.entry entry = device.entry
@ -1378,10 +1295,7 @@ async def test_disconnects_at_close_event(
"""Test the device is disconnected at the close event.""" """Test the device is disconnected at the close event."""
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
device_info={"compilation_time": "comp_time"}, device_info={"compilation_time": "comp_time"},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -1410,10 +1324,7 @@ async def test_start_reauth(
"""Test exceptions on connect error trigger reauth.""" """Test exceptions on connect error trigger reauth."""
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
device_info={"compilation_time": "comp_time"}, device_info={"compilation_time": "comp_time"},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -1435,10 +1346,7 @@ async def test_no_reauth_wrong_mac(
"""Test exceptions on connect error trigger reauth.""" """Test exceptions on connect error trigger reauth."""
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
device_info={"compilation_time": "comp_time"}, device_info={"compilation_time": "comp_time"},
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -1514,14 +1422,9 @@ async def test_device_adds_friendly_name(
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
) -> None: ) -> None:
"""Test a device with user services that change arguments.""" """Test a device with user services that change arguments."""
entity_info = []
states = []
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info,
user_service=[],
device_info={"name": "nofriendlyname", "friendly_name": ""}, device_info={"name": "nofriendlyname", "friendly_name": ""},
states=states,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
dev_reg = dr.async_get(hass) dev_reg = dr.async_get(hass)
@ -1582,10 +1485,7 @@ async def test_assist_in_progress_issue_deleted(
) )
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
device_info={}, device_info={},
states=[],
mock_storage=True, mock_storage=True,
) )
assert ( assert (

View File

@ -328,7 +328,6 @@ async def test_media_player_proxy(
], ],
) )
], ],
user_service=[],
states=[ states=[
MediaPlayerEntityState( MediaPlayerEntityState(
key=1, volume=50, muted=False, state=MediaPlayerState.PAUSED key=1, volume=50, muted=False, state=MediaPlayerState.PAUSED

View File

@ -107,9 +107,6 @@ async def test_wake_word_select_no_wake_words(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.ANNOUNCE | VoiceAssistantFeature.ANNOUNCE
@ -144,9 +141,6 @@ async def test_wake_word_select_zero_max_wake_words(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.ANNOUNCE | VoiceAssistantFeature.ANNOUNCE
@ -182,9 +176,6 @@ async def test_wake_word_select_no_active_wake_words(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={ device_info={
"voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT "voice_assistant_feature_flags": VoiceAssistantFeature.VOICE_ASSISTANT
| VoiceAssistantFeature.ANNOUNCE | VoiceAssistantFeature.ANNOUNCE

View File

@ -99,9 +99,6 @@ async def test_update_entity(
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
state = hass.states.get("update.test_firmware") state = hass.states.get("update.test_firmware")
@ -210,9 +207,6 @@ async def test_update_static_info(
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
state = hass.states.get("update.test_firmware") state = hass.states.get("update.test_firmware")
@ -257,9 +251,6 @@ async def test_update_device_state_for_availability(
await async_get_dashboard(hass).async_refresh() await async_get_dashboard(hass).async_refresh()
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={"has_deep_sleep": has_deep_sleep}, device_info={"has_deep_sleep": has_deep_sleep},
) )
@ -287,9 +278,6 @@ async def test_update_entity_dashboard_not_available_startup(
await async_get_dashboard(hass).async_refresh() await async_get_dashboard(hass).async_refresh()
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
# We have a dashboard but it is not available # We have a dashboard but it is not available
@ -332,9 +320,6 @@ async def test_update_entity_dashboard_discovered_after_startup_but_update_faile
await hass.async_block_till_done() await hass.async_block_till_done()
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get("update.test_firmware") state = hass.states.get("update.test_firmware")
@ -372,9 +357,6 @@ async def test_update_entity_not_present_without_dashboard(
"""Test ESPHome update entity does not get created if there is no dashboard.""" """Test ESPHome update entity does not get created if there is no dashboard."""
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
state = hass.states.get("update.test_firmware") state = hass.states.get("update.test_firmware")
@ -390,9 +372,6 @@ async def test_update_becomes_available_at_runtime(
"""Test ESPHome update entity when the dashboard has no device at startup but gets them later.""" """Test ESPHome update entity when the dashboard has no device at startup but gets them later."""
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get("update.test_firmware") state = hass.states.get("update.test_firmware")
@ -426,9 +405,6 @@ async def test_update_entity_not_present_with_dashboard_but_unknown_device(
"""Test ESPHome update entity does not get created if the device is unknown to the dashboard.""" """Test ESPHome update entity does not get created if the device is unknown to the dashboard."""
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
mock_dashboard["configured"] = [ mock_dashboard["configured"] = [
@ -473,11 +449,9 @@ async def test_generic_device_update_entity(
release_url=RELEASE_URL, release_url=RELEASE_URL,
) )
] ]
user_service = []
await mock_generic_device_entry( await mock_generic_device_entry(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
) )
state = hass.states.get(ENTITY_ID) state = hass.states.get(ENTITY_ID)
@ -509,11 +483,9 @@ async def test_generic_device_update_entity_has_update(
release_url=RELEASE_URL, release_url=RELEASE_URL,
) )
] ]
user_service = []
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=states, states=states,
) )
state = hass.states.get(ENTITY_ID) state = hass.states.get(ENTITY_ID)
@ -591,11 +563,9 @@ async def test_update_entity_release_notes(
) )
] ]
user_service = []
mock_device = await mock_esphome_device( mock_device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=entity_info, entity_info=entity_info,
user_service=user_service,
states=[], states=[],
) )
@ -676,9 +646,6 @@ async def test_attempt_to_update_twice(
await async_get_dashboard(hass).async_refresh() await async_get_dashboard(hass).async_refresh()
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
) )
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get("update.test_firmware") state = hass.states.get("update.test_firmware")
@ -738,9 +705,6 @@ async def test_update_deep_sleep_already_online(
await async_get_dashboard(hass).async_refresh() await async_get_dashboard(hass).async_refresh()
await mock_esphome_device( await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={"has_deep_sleep": True}, device_info={"has_deep_sleep": True},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -783,9 +747,6 @@ async def test_update_deep_sleep_offline(
await async_get_dashboard(hass).async_refresh() await async_get_dashboard(hass).async_refresh()
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={"has_deep_sleep": True}, device_info={"has_deep_sleep": True},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -835,9 +796,6 @@ async def test_update_deep_sleep_offline_sleep_during_ota(
await async_get_dashboard(hass).async_refresh() await async_get_dashboard(hass).async_refresh()
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={"has_deep_sleep": True}, device_info={"has_deep_sleep": True},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -916,9 +874,6 @@ async def test_update_deep_sleep_offline_cancelled_unload(
await async_get_dashboard(hass).async_refresh() await async_get_dashboard(hass).async_refresh()
device = await mock_esphome_device( device = await mock_esphome_device(
mock_client=mock_client, mock_client=mock_client,
entity_info=[],
user_service=[],
states=[],
device_info={"has_deep_sleep": True}, device_info={"has_deep_sleep": True},
) )
await hass.async_block_till_done() await hass.async_block_till_done()