From cf5652737a5c2f03a51846f91d27afb98767be3c Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 16 Feb 2022 09:29:52 +0100 Subject: [PATCH] Cleanup samsungtv tests (#66570) * Drop unused init method * Add type hints to media_player tests * Adjust test_init * Adjust media_player * Add type hints to conftest * Use Mock in test_media_player * Use lowercase in test_init * Use relative import in diagnostics * Add type hints to config_flow * Adjust coveragerc * Make gethostbyname autouse * Cleanup gethostbyname and remote fixtures * Drop unused fixtures * Undo type hints and usefixtures on media_player * Undo type hints and usefixtures in test_init * Undo type hints in conftest * Undo usefixtures in test_config_flow * Format Co-authored-by: epenet --- .coveragerc | 1 - tests/components/samsungtv/__init__.py | 13 -- tests/components/samsungtv/conftest.py | 33 ++--- .../components/samsungtv/test_config_flow.py | 134 ++++++------------ .../components/samsungtv/test_diagnostics.py | 3 +- tests/components/samsungtv/test_init.py | 49 +++---- .../components/samsungtv/test_media_player.py | 18 ++- 7 files changed, 84 insertions(+), 167 deletions(-) diff --git a/.coveragerc b/.coveragerc index aa64e660a833..32cb61a4921b 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1006,7 +1006,6 @@ omit = homeassistant/components/russound_rnet/media_player.py homeassistant/components/sabnzbd/* homeassistant/components/saj/sensor.py - homeassistant/components/samsungtv/bridge.py homeassistant/components/satel_integra/* homeassistant/components/schluter/* homeassistant/components/screenlogic/__init__.py diff --git a/tests/components/samsungtv/__init__.py b/tests/components/samsungtv/__init__.py index 897682216657..4ad1622c6cae 100644 --- a/tests/components/samsungtv/__init__.py +++ b/tests/components/samsungtv/__init__.py @@ -1,14 +1 @@ """Tests for the samsungtv component.""" -from homeassistant.components.samsungtv.const import DOMAIN as SAMSUNGTV_DOMAIN -from homeassistant.core import HomeAssistant - -from tests.common import MockConfigEntry - - -async def setup_samsungtv(hass: HomeAssistant, config: dict): - """Set up mock Samsung TV.""" - - entry = MockConfigEntry(domain=SAMSUNGTV_DOMAIN, data=config) - entry.add_to_hass(hass) - assert await hass.config_entries.async_setup(entry.entry_id) - await hass.async_block_till_done() diff --git a/tests/components/samsungtv/conftest.py b/tests/components/samsungtv/conftest.py index 05c51fdf5911..f14a0f71bf1c 100644 --- a/tests/components/samsungtv/conftest.py +++ b/tests/components/samsungtv/conftest.py @@ -5,19 +5,21 @@ import pytest import homeassistant.util.dt as dt_util -RESULT_ALREADY_CONFIGURED = "already_configured" -RESULT_ALREADY_IN_PROGRESS = "already_in_progress" + +@pytest.fixture(autouse=True) +def fake_host_fixture() -> None: + """Patch gethostbyname.""" + with patch( + "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", + return_value="fake_host", + ): + yield @pytest.fixture(name="remote") def remote_fixture(): """Patch the samsungctl Remote.""" - with patch( - "homeassistant.components.samsungtv.bridge.Remote" - ) as remote_class, patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): + with patch("homeassistant.components.samsungtv.bridge.Remote") as remote_class: remote = Mock() remote.__enter__ = Mock() remote.__exit__ = Mock() @@ -31,10 +33,7 @@ def remotews_fixture(): """Patch the samsungtvws SamsungTVWS.""" with patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS" - ) as remotews_class, patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): + ) as remotews_class: remotews = Mock() remotews.__enter__ = Mock() remotews.__exit__ = Mock() @@ -59,10 +58,7 @@ def remotews_no_device_info_fixture(): """Patch the samsungtvws SamsungTVWS.""" with patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS" - ) as remotews_class, patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): + ) as remotews_class: remotews = Mock() remotews.__enter__ = Mock() remotews.__exit__ = Mock() @@ -77,10 +73,7 @@ def remotews_soundbar_fixture(): """Patch the samsungtvws SamsungTVWS.""" with patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS" - ) as remotews_class, patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): + ) as remotews_class: remotews = Mock() remotews.__enter__ = Mock() remotews.__exit__ = Mock() diff --git a/tests/components/samsungtv/test_config_flow.py b/tests/components/samsungtv/test_config_flow.py index 199c7d87eed4..57bb99354dc0 100644 --- a/tests/components/samsungtv/test_config_flow.py +++ b/tests/components/samsungtv/test_config_flow.py @@ -43,10 +43,9 @@ from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry -from tests.components.samsungtv.conftest import ( - RESULT_ALREADY_CONFIGURED, - RESULT_ALREADY_IN_PROGRESS, -) + +RESULT_ALREADY_CONFIGURED = "already_configured" +RESULT_ALREADY_IN_PROGRESS = "already_in_progress" MOCK_IMPORT_DATA = { CONF_HOST: "fake_host", @@ -233,9 +232,7 @@ async def test_user_websocket(hass: HomeAssistant, remotews: Mock): assert result["result"].unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4" -async def test_user_legacy_missing_auth( - hass: HomeAssistant, remote: Mock, remotews: Mock -): +async def test_user_legacy_missing_auth(hass: HomeAssistant, remotews: Mock): """Test starting a flow by user with authentication.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -249,7 +246,7 @@ async def test_user_legacy_missing_auth( assert result["reason"] == RESULT_AUTH_MISSING -async def test_user_legacy_not_supported(hass: HomeAssistant, remote: Mock): +async def test_user_legacy_not_supported(hass: HomeAssistant): """Test starting a flow by user for not supported device.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -263,7 +260,7 @@ async def test_user_legacy_not_supported(hass: HomeAssistant, remote: Mock): assert result["reason"] == RESULT_NOT_SUPPORTED -async def test_user_websocket_not_supported(hass: HomeAssistant, remotews: Mock): +async def test_user_websocket_not_supported(hass: HomeAssistant): """Test starting a flow by user for not supported device.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -280,7 +277,7 @@ async def test_user_websocket_not_supported(hass: HomeAssistant, remotews: Mock) assert result["reason"] == RESULT_NOT_SUPPORTED -async def test_user_not_successful(hass: HomeAssistant, remotews: Mock): +async def test_user_not_successful(hass: HomeAssistant): """Test starting a flow by user but no connection found.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -296,7 +293,7 @@ async def test_user_not_successful(hass: HomeAssistant, remotews: Mock): assert result["reason"] == RESULT_CANNOT_CONNECT -async def test_user_not_successful_2(hass: HomeAssistant, remotews: Mock): +async def test_user_not_successful_2(hass: HomeAssistant): """Test starting a flow by user but no connection found.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -375,9 +372,7 @@ async def test_ssdp_noprefix(hass: HomeAssistant, remote: Mock, no_mac_address: assert result["result"].unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172df" -async def test_ssdp_legacy_missing_auth( - hass: HomeAssistant, remote: Mock, remotews: Mock -): +async def test_ssdp_legacy_missing_auth(hass: HomeAssistant, remotews: Mock): """Test starting a flow from discovery with authentication.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -453,7 +448,7 @@ async def test_ssdp_websocket_success_populates_mac_address( assert result["result"].unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de" -async def test_ssdp_websocket_not_supported(hass: HomeAssistant, remote: Mock): +async def test_ssdp_websocket_not_supported(hass: HomeAssistant): """Test starting a flow from discovery for not supported device.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -483,9 +478,7 @@ async def test_ssdp_model_not_supported(hass: HomeAssistant, remote: Mock): assert result["reason"] == RESULT_NOT_SUPPORTED -async def test_ssdp_not_successful( - hass: HomeAssistant, remote: Mock, no_mac_address: Mock -): +async def test_ssdp_not_successful(hass: HomeAssistant, no_mac_address: Mock): """Test starting a flow from discovery but no device found.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -513,9 +506,7 @@ async def test_ssdp_not_successful( assert result["reason"] == RESULT_CANNOT_CONNECT -async def test_ssdp_not_successful_2( - hass: HomeAssistant, remote: Mock, no_mac_address: Mock -): +async def test_ssdp_not_successful_2(hass: HomeAssistant, no_mac_address: Mock): """Test starting a flow from discovery but no device found.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -605,15 +596,11 @@ async def test_import_legacy(hass: HomeAssistant, remote: Mock, no_mac_address: """Test importing from yaml with hostname.""" no_mac_address.return_value = "aa:bb:cc:dd:ee:ff" - with patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=MOCK_IMPORT_DATA, - ) + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=MOCK_IMPORT_DATA, + ) await hass.async_block_till_done() assert result["type"] == "create_entry" assert result["title"] == "fake" @@ -635,15 +622,11 @@ async def test_import_legacy_without_name( no_mac_address: Mock, ): """Test importing from yaml without a name.""" - with patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=MOCK_IMPORT_DATA_WITHOUT_NAME, - ) + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=MOCK_IMPORT_DATA_WITHOUT_NAME, + ) await hass.async_block_till_done() assert result["type"] == "create_entry" assert result["title"] == "fake_host" @@ -659,15 +642,11 @@ async def test_import_legacy_without_name( async def test_import_websocket(hass: HomeAssistant, remotews: Mock): """Test importing from yaml with hostname.""" - with patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=MOCK_IMPORT_WSDATA, - ) + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=MOCK_IMPORT_WSDATA, + ) await hass.async_block_till_done() assert result["type"] == "create_entry" assert result["title"] == "fake" @@ -681,15 +660,11 @@ async def test_import_websocket(hass: HomeAssistant, remotews: Mock): async def test_import_websocket_without_port(hass: HomeAssistant, remotews: Mock): """Test importing from yaml with hostname by no port.""" - with patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=MOCK_IMPORT_WSDATA, - ) + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data=MOCK_IMPORT_WSDATA, + ) await hass.async_block_till_done() assert result["type"] == "create_entry" assert result["title"] == "fake" @@ -818,17 +793,12 @@ async def test_zeroconf_and_dhcp_same_time(hass: HomeAssistant, remotews: Mock): assert result2["reason"] == "already_in_progress" -async def test_autodetect_websocket(hass: HomeAssistant, remote: Mock, remotews: Mock): +async def test_autodetect_websocket(hass: HomeAssistant): """Test for send key with autodetection of protocol.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), - ), patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ), patch( - "homeassistant.components.samsungtv.bridge.SamsungTVWS" - ) as remotews: + ), patch("homeassistant.components.samsungtv.bridge.SamsungTVWS") as remotews: enter = Mock() type(enter).token = PropertyMock(return_value="123456789") remote = Mock() @@ -866,14 +836,11 @@ async def test_autodetect_websocket(hass: HomeAssistant, remote: Mock, remotews: assert entries[0].data[CONF_MAC] == "aa:bb:cc:dd:ee:ff" -async def test_websocket_no_mac(hass: HomeAssistant, remote: Mock, remotews: Mock): +async def test_websocket_no_mac(hass: HomeAssistant): """Test for send key with autodetection of protocol.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom"), - ), patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", ), patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS" ) as remotews, patch( @@ -915,15 +882,12 @@ async def test_websocket_no_mac(hass: HomeAssistant, remote: Mock, remotews: Moc assert entries[0].data[CONF_MAC] == "gg:hh:ii:ll:mm:nn" -async def test_autodetect_auth_missing(hass: HomeAssistant, remote: Mock): +async def test_autodetect_auth_missing(hass: HomeAssistant): """Test for send key with autodetection of protocol.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[AccessDenied("Boom")], - ) as remote, patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): + ) as remote: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA ) @@ -933,15 +897,12 @@ async def test_autodetect_auth_missing(hass: HomeAssistant, remote: Mock): assert remote.call_args_list == [call(AUTODETECT_LEGACY)] -async def test_autodetect_not_supported(hass: HomeAssistant, remote: Mock): +async def test_autodetect_not_supported(hass: HomeAssistant): """Test for send key with autodetection of protocol.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[UnhandledResponse("Boom")], - ) as remote, patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): + ) as remote: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA ) @@ -963,7 +924,7 @@ async def test_autodetect_legacy(hass: HomeAssistant, remote: Mock): assert result["data"][CONF_PORT] == LEGACY_PORT -async def test_autodetect_none(hass: HomeAssistant, remote: Mock, remotews: Mock): +async def test_autodetect_none(hass: HomeAssistant): """Test for send key with autodetection of protocol.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", @@ -971,10 +932,7 @@ async def test_autodetect_none(hass: HomeAssistant, remote: Mock, remotews: Mock ) as remote, patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=OSError("Boom"), - ) as remotews, patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): + ) as remotews: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA ) @@ -991,7 +949,7 @@ async def test_autodetect_none(hass: HomeAssistant, remote: Mock, remotews: Mock ] -async def test_update_old_entry(hass: HomeAssistant, remote: Mock, remotews: Mock): +async def test_update_old_entry(hass: HomeAssistant, remotews: Mock): """Test update of old entry.""" with patch("homeassistant.components.samsungtv.bridge.Remote") as remote: remote().rest_device_info.return_value = { @@ -1267,9 +1225,6 @@ async def test_form_reauth_websocket_cannot_connect(hass, remotews: Mock): with patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=ConnectionFailure, - ), patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -1290,7 +1245,7 @@ async def test_form_reauth_websocket_cannot_connect(hass, remotews: Mock): assert result3["reason"] == "reauth_successful" -async def test_form_reauth_websocket_not_supported(hass, remotews: Mock): +async def test_form_reauth_websocket_not_supported(hass): """Test reauthenticate websocket when the device is not supported.""" entry = MockConfigEntry(domain=DOMAIN, data=MOCK_WS_ENTRY) entry.add_to_hass(hass) @@ -1305,9 +1260,6 @@ async def test_form_reauth_websocket_not_supported(hass, remotews: Mock): with patch( "homeassistant.components.samsungtv.bridge.SamsungTVWS", side_effect=WebSocketException, - ), patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/samsungtv/test_diagnostics.py b/tests/components/samsungtv/test_diagnostics.py index ba3d03d5702c..990c25c8f3e8 100644 --- a/tests/components/samsungtv/test_diagnostics.py +++ b/tests/components/samsungtv/test_diagnostics.py @@ -7,9 +7,10 @@ from homeassistant.components.samsungtv import DOMAIN from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant +from .test_media_player import MOCK_ENTRY_WS_WITH_MAC + from tests.common import MockConfigEntry from tests.components.diagnostics import get_diagnostics_for_config_entry -from tests.components.samsungtv.test_media_player import MOCK_ENTRY_WS_WITH_MAC @pytest.fixture(name="config_entry") diff --git a/tests/components/samsungtv/test_init.py b/tests/components/samsungtv/test_init.py index bd3e2a512564..e49b8fdc5ee9 100644 --- a/tests/components/samsungtv/test_init.py +++ b/tests/components/samsungtv/test_init.py @@ -55,27 +55,21 @@ REMOTE_CALL = { async def test_setup(hass: HomeAssistant, remotews: Mock, no_mac_address: Mock): """Test Samsung TV integration is setup.""" - with patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): + await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG) + await hass.async_block_till_done() + state = hass.states.get(ENTITY_ID) - await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG) - await hass.async_block_till_done() - state = hass.states.get(ENTITY_ID) + # test name and turn_on + assert state + assert state.name == "fake_name" + assert ( + state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORT_SAMSUNGTV | SUPPORT_TURN_ON + ) - # test name and turn_on - assert state - assert state.name == "fake_name" - assert ( - state.attributes[ATTR_SUPPORTED_FEATURES] - == SUPPORT_SAMSUNGTV | SUPPORT_TURN_ON - ) - - # test host and port - assert await hass.services.async_call( - DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True - ) + # test host and port + assert await hass.services.async_call( + DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True + ) async def test_setup_from_yaml_without_port_device_offline(hass: HomeAssistant): @@ -88,9 +82,6 @@ async def test_setup_from_yaml_without_port_device_offline(hass: HomeAssistant): ), patch( "homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.device_info", return_value=None, - ), patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", ): await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG) await hass.async_block_till_done() @@ -104,12 +95,8 @@ async def test_setup_from_yaml_without_port_device_online( hass: HomeAssistant, remotews: Mock ): """Test import from yaml when the device is online.""" - with patch( - "homeassistant.components.samsungtv.config_flow.socket.gethostbyname", - return_value="fake_host", - ): - await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG) - await hass.async_block_till_done() + await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG) + await hass.async_block_till_done() config_entries_domain = hass.config_entries.async_entries(SAMSUNGTV_DOMAIN) assert len(config_entries_domain) == 1 @@ -118,13 +105,13 @@ async def test_setup_from_yaml_without_port_device_online( async def test_setup_duplicate_config(hass: HomeAssistant, remote: Mock, caplog): """Test duplicate setup of platform.""" - DUPLICATE = { + duplicate = { SAMSUNGTV_DOMAIN: [ MOCK_CONFIG[SAMSUNGTV_DOMAIN][0], MOCK_CONFIG[SAMSUNGTV_DOMAIN][0], ] } - await async_setup_component(hass, SAMSUNGTV_DOMAIN, DUPLICATE) + await async_setup_component(hass, SAMSUNGTV_DOMAIN, duplicate) await hass.async_block_till_done() assert hass.states.get(ENTITY_ID) is None assert len(hass.states.async_all("media_player")) == 0 @@ -132,7 +119,7 @@ async def test_setup_duplicate_config(hass: HomeAssistant, remote: Mock, caplog) async def test_setup_duplicate_entries( - hass: HomeAssistant, remote: Mock, remotews: Mock, no_mac_address: Mock, caplog + hass: HomeAssistant, remote: Mock, remotews: Mock, no_mac_address: Mock ): """Test duplicate setup of platform.""" await async_setup_component(hass, SAMSUNGTV_DOMAIN, MOCK_CONFIG) diff --git a/tests/components/samsungtv/test_media_player.py b/tests/components/samsungtv/test_media_player.py index dca7e4366f3e..2d8c07c22cf9 100644 --- a/tests/components/samsungtv/test_media_player.py +++ b/tests/components/samsungtv/test_media_player.py @@ -117,6 +117,9 @@ MOCK_CONFIG_NOTURNON = { ] } +# Fake mac address in all mediaplayer tests. +pytestmark = pytest.mark.usefixtures("no_mac_address") + @pytest.fixture(name="delay") def delay_fixture(): @@ -127,11 +130,6 @@ def delay_fixture(): yield delay -@pytest.fixture(autouse=True) -def mock_no_mac_address(no_mac_address): - """Fake mac address in all mediaplayer tests.""" - - async def setup_samsungtv(hass, config): """Set up mock Samsung TV.""" await async_setup_component(hass, SAMSUNGTV_DOMAIN, config) @@ -150,7 +148,7 @@ async def test_setup_without_turnon(hass, remote): assert hass.states.get(ENTITY_ID_NOTURNON) -async def test_setup_websocket(hass, remotews, mock_now): +async def test_setup_websocket(hass, remotews): """Test setup of platform.""" with patch("homeassistant.components.samsungtv.bridge.SamsungTVWS") as remote_class: enter = Mock() @@ -742,7 +740,7 @@ async def test_play_media(hass, remote): assert len(sleeps) == 3 -async def test_play_media_invalid_type(hass, remote): +async def test_play_media_invalid_type(hass): """Test for play_media with invalid media type.""" with patch("homeassistant.components.samsungtv.bridge.Remote") as remote: url = "https://example.com" @@ -764,7 +762,7 @@ async def test_play_media_invalid_type(hass, remote): assert remote.call_count == 1 -async def test_play_media_channel_as_string(hass, remote): +async def test_play_media_channel_as_string(hass): """Test for play_media with invalid channel as string.""" with patch("homeassistant.components.samsungtv.bridge.Remote") as remote: url = "https://example.com" @@ -786,7 +784,7 @@ async def test_play_media_channel_as_string(hass, remote): assert remote.call_count == 1 -async def test_play_media_channel_as_non_positive(hass, remote): +async def test_play_media_channel_as_non_positive(hass): """Test for play_media with invalid channel as non positive integer.""" with patch("homeassistant.components.samsungtv.bridge.Remote") as remote: await setup_samsungtv(hass, MOCK_CONFIG) @@ -823,7 +821,7 @@ async def test_select_source(hass, remote): assert remote.close.call_args_list == [call()] -async def test_select_source_invalid_source(hass, remote): +async def test_select_source_invalid_source(hass): """Test for select_source with invalid source.""" with patch("homeassistant.components.samsungtv.bridge.Remote") as remote: await setup_samsungtv(hass, MOCK_CONFIG)