mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix init slow tests for SamsungTV (#60245)
This commit is contained in:
parent
1a5f2c9c32
commit
8e6a3b2799
@ -1,5 +1,5 @@
|
|||||||
"""Tests for the Samsung TV Integration."""
|
"""Tests for the Samsung TV Integration."""
|
||||||
from unittest.mock import Mock, call, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from homeassistant.components.media_player.const import DOMAIN, SUPPORT_TURN_ON
|
from homeassistant.components.media_player.const import DOMAIN, SUPPORT_TURN_ON
|
||||||
from homeassistant.components.samsungtv.const import (
|
from homeassistant.components.samsungtv.const import (
|
||||||
@ -53,13 +53,13 @@ REMOTE_CALL = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_setup(hass: HomeAssistant, remote: Mock, no_mac_address: Mock):
|
async def test_setup(hass: HomeAssistant, remotews: Mock, no_mac_address: Mock):
|
||||||
"""Test Samsung TV integration is setup."""
|
"""Test Samsung TV integration is setup."""
|
||||||
with patch("homeassistant.components.samsungtv.bridge.Remote") as remote, patch(
|
with patch(
|
||||||
"homeassistant.components.samsungtv.config_flow.socket.gethostbyname",
|
"homeassistant.components.samsungtv.config_flow.socket.gethostbyname",
|
||||||
return_value="fake_host",
|
return_value="fake_host",
|
||||||
):
|
):
|
||||||
with patch("homeassistant.components.samsungtv.bridge.Remote") as remote:
|
|
||||||
await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG)
|
await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
state = hass.states.get(ENTITY_ID)
|
state = hass.states.get(ENTITY_ID)
|
||||||
@ -76,7 +76,6 @@ async def test_setup(hass: HomeAssistant, remote: Mock, no_mac_address: Mock):
|
|||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||||
)
|
)
|
||||||
assert remote.call_args == call(REMOTE_CALL)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_from_yaml_without_port_device_offline(hass: HomeAssistant):
|
async def test_setup_from_yaml_without_port_device_offline(hass: HomeAssistant):
|
||||||
@ -86,6 +85,9 @@ async def test_setup_from_yaml_without_port_device_offline(hass: HomeAssistant):
|
|||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.samsungtv.bridge.SamsungTVWS.open",
|
"homeassistant.components.samsungtv.bridge.SamsungTVWS.open",
|
||||||
side_effect=OSError,
|
side_effect=OSError,
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.device_info",
|
||||||
|
return_value=None,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.samsungtv.config_flow.socket.gethostbyname",
|
"homeassistant.components.samsungtv.config_flow.socket.gethostbyname",
|
||||||
return_value="fake_host",
|
return_value="fake_host",
|
||||||
@ -130,7 +132,7 @@ async def test_setup_duplicate_config(hass: HomeAssistant, remote: Mock, caplog)
|
|||||||
|
|
||||||
|
|
||||||
async def test_setup_duplicate_entries(
|
async def test_setup_duplicate_entries(
|
||||||
hass: HomeAssistant, remote: Mock, no_mac_address: Mock, caplog
|
hass: HomeAssistant, remote: Mock, remotews: Mock, no_mac_address: Mock, caplog
|
||||||
):
|
):
|
||||||
"""Test duplicate setup of platform."""
|
"""Test duplicate setup of platform."""
|
||||||
await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG)
|
await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user