Remove references to hass.data in harmony tests (#49836)
Instead, just use the mocks directly.pull/49841/head
parent
27816aa4d5
commit
1c0fd61075
|
@ -6,7 +6,6 @@ from aioharmony.const import SendCommandDevice
|
|||
|
||||
from homeassistant.components.harmony.const import (
|
||||
DOMAIN,
|
||||
HARMONY_DATA,
|
||||
SERVICE_CHANGE_CHANNEL,
|
||||
SERVICE_SYNC,
|
||||
)
|
||||
|
@ -150,7 +149,7 @@ async def test_remote_toggles(mock_hc, hass, mock_write_config):
|
|||
assert hass.states.is_state(ENTITY_PLAY_MUSIC, STATE_OFF)
|
||||
|
||||
|
||||
async def test_async_send_command(mock_hc, hass, mock_write_config):
|
||||
async def test_async_send_command(mock_hc, harmony_client, hass, mock_write_config):
|
||||
"""Ensure calls to send remote commands properly propagate to devices."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, data={CONF_HOST: "192.0.2.0", CONF_NAME: HUB_NAME}
|
||||
|
@ -160,8 +159,7 @@ async def test_async_send_command(mock_hc, hass, mock_write_config):
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
data = hass.data[DOMAIN][entry.entry_id][HARMONY_DATA]
|
||||
send_commands_mock = data._client.send_commands
|
||||
send_commands_mock = harmony_client.send_commands
|
||||
|
||||
# No device provided
|
||||
await _send_commands_and_wait(
|
||||
|
@ -283,7 +281,9 @@ async def test_async_send_command(mock_hc, hass, mock_write_config):
|
|||
send_commands_mock.reset_mock()
|
||||
|
||||
|
||||
async def test_async_send_command_custom_delay(mock_hc, hass, mock_write_config):
|
||||
async def test_async_send_command_custom_delay(
|
||||
mock_hc, harmony_client, hass, mock_write_config
|
||||
):
|
||||
"""Ensure calls to send remote commands properly propagate to devices with custom delays."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -298,8 +298,7 @@ async def test_async_send_command_custom_delay(mock_hc, hass, mock_write_config)
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
data = hass.data[DOMAIN][entry.entry_id][HARMONY_DATA]
|
||||
send_commands_mock = data._client.send_commands
|
||||
send_commands_mock = harmony_client.send_commands
|
||||
|
||||
# Tell the TV to play by id
|
||||
await _send_commands_and_wait(
|
||||
|
@ -324,7 +323,7 @@ async def test_async_send_command_custom_delay(mock_hc, hass, mock_write_config)
|
|||
send_commands_mock.reset_mock()
|
||||
|
||||
|
||||
async def test_change_channel(mock_hc, hass, mock_write_config):
|
||||
async def test_change_channel(mock_hc, harmony_client, hass, mock_write_config):
|
||||
"""Test change channel commands."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, data={CONF_HOST: "192.0.2.0", CONF_NAME: HUB_NAME}
|
||||
|
@ -334,8 +333,7 @@ async def test_change_channel(mock_hc, hass, mock_write_config):
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
data = hass.data[DOMAIN][entry.entry_id][HARMONY_DATA]
|
||||
change_channel_mock = data._client.change_channel
|
||||
change_channel_mock = harmony_client.change_channel
|
||||
|
||||
# Tell the remote to change channels
|
||||
await hass.services.async_call(
|
||||
|
@ -349,7 +347,7 @@ async def test_change_channel(mock_hc, hass, mock_write_config):
|
|||
change_channel_mock.assert_awaited_once_with(100)
|
||||
|
||||
|
||||
async def test_sync(mock_hc, mock_write_config, hass):
|
||||
async def test_sync(mock_hc, harmony_client, mock_write_config, hass):
|
||||
"""Test the sync command."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, data={CONF_HOST: "192.0.2.0", CONF_NAME: HUB_NAME}
|
||||
|
@ -359,8 +357,7 @@ async def test_sync(mock_hc, mock_write_config, hass):
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
data = hass.data[DOMAIN][entry.entry_id][HARMONY_DATA]
|
||||
sync_mock = data._client.sync
|
||||
sync_mock = harmony_client.sync
|
||||
|
||||
# Tell the remote to change channels
|
||||
await hass.services.async_call(
|
||||
|
|
Loading…
Reference in New Issue