diff --git a/tests/components/cast/test_media_player.py b/tests/components/cast/test_media_player.py index 93df75db8ba..2f21a1c0f31 100644 --- a/tests/components/cast/test_media_player.py +++ b/tests/components/cast/test_media_player.py @@ -22,13 +22,18 @@ from tests.common import MockConfigEntry, mock_coro def cast_mock(): """Mock pychromecast.""" pycast_mock = MagicMock() + dial_mock = MagicMock(name="XXX") + dial_mock.get_device_status.return_value.uuid = "fake_uuid" + dial_mock.get_device_status.return_value.manufacturer = "fake_manufacturer" + dial_mock.get_device_status.return_value.model_name = "fake_model_name" + dial_mock.get_device_status.return_value.friendly_name = "fake_friendly_name" with patch( "homeassistant.components.cast.media_player.pychromecast", pycast_mock ), patch( "homeassistant.components.cast.discovery.pychromecast", pycast_mock ), patch( - "homeassistant.components.cast.helpers.dial", MagicMock() + "homeassistant.components.cast.helpers.dial", dial_mock ), patch( "homeassistant.components.cast.media_player.MultizoneManager", MagicMock() ): @@ -127,7 +132,7 @@ async def test_start_discovery_called_once(hass): """Test pychromecast.start_discovery called exactly once.""" with patch( "homeassistant.components.cast.discovery.pychromecast.start_discovery", - return_value=(None, None), + return_value=(None, Mock()), ) as start_discovery: await async_setup_cast(hass) diff --git a/tests/components/discovery/test_init.py b/tests/components/discovery/test_init.py index 1d11bba9e16..86865209de3 100644 --- a/tests/components/discovery/test_init.py +++ b/tests/components/discovery/test_init.py @@ -1,6 +1,7 @@ """The tests for the discovery component.""" -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock +from asynctest import patch import pytest from homeassistant import config_entries diff --git a/tests/components/smartthings/test_init.py b/tests/components/smartthings/test_init.py index ae80316676a..05ea832a81e 100644 --- a/tests/components/smartthings/test_init.py +++ b/tests/components/smartthings/test_init.py @@ -157,8 +157,8 @@ async def test_scenes_unauthorized_loads_platforms( request_info=request_info, history=None, status=403 ) mock_token = Mock() - mock_token.access_token.return_value = str(uuid4()) - mock_token.refresh_token.return_value = str(uuid4()) + mock_token.access_token = str(uuid4()) + mock_token.refresh_token = str(uuid4()) smartthings_mock.generate_tokens.return_value = mock_token subscriptions = [ subscription_factory(capability) for capability in device.capabilities @@ -189,8 +189,8 @@ async def test_config_entry_loads_platforms( smartthings_mock.devices.return_value = [device] smartthings_mock.scenes.return_value = [scene] mock_token = Mock() - mock_token.access_token.return_value = str(uuid4()) - mock_token.refresh_token.return_value = str(uuid4()) + mock_token.access_token = str(uuid4()) + mock_token.refresh_token = str(uuid4()) smartthings_mock.generate_tokens.return_value = mock_token subscriptions = [ subscription_factory(capability) for capability in device.capabilities @@ -223,8 +223,8 @@ async def test_config_entry_loads_unconnected_cloud( smartthings_mock.devices.return_value = [device] smartthings_mock.scenes.return_value = [scene] mock_token = Mock() - mock_token.access_token.return_value = str(uuid4()) - mock_token.refresh_token.return_value = str(uuid4()) + mock_token.access_token = str(uuid4()) + mock_token.refresh_token = str(uuid4()) smartthings_mock.generate_tokens.return_value = mock_token subscriptions = [ subscription_factory(capability) for capability in device.capabilities diff --git a/tests/components/spotify/test_config_flow.py b/tests/components/spotify/test_config_flow.py index eabaa57d3a8..3644ca462ca 100644 --- a/tests/components/spotify/test_config_flow.py +++ b/tests/components/spotify/test_config_flow.py @@ -86,7 +86,8 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock): }, ) - with patch("homeassistant.components.spotify.config_flow.Spotify"): + with patch("homeassistant.components.spotify.config_flow.Spotify") as spotify_mock: + spotify_mock.return_value.current_user.return_value = {"id": "fake_id"} result = await hass.config_entries.flow.async_configure(result["flow_id"]) assert result["data"]["auth_implementation"] == DOMAIN diff --git a/tests/components/unifi_direct/test_device_tracker.py b/tests/components/unifi_direct/test_device_tracker.py index 297bf917dbf..692231d4cad 100644 --- a/tests/components/unifi_direct/test_device_tracker.py +++ b/tests/components/unifi_direct/test_device_tracker.py @@ -16,6 +16,7 @@ from homeassistant.components.unifi_direct.device_tracker import ( CONF_PORT, DOMAIN, PLATFORM_SCHEMA, + UnifiDeviceScanner, _response_to_json, get_scanner, ) @@ -37,7 +38,7 @@ def setup_comp(hass): os.remove(yaml_devices) -@patch(scanner_path, return_value=mock.MagicMock()) +@patch(scanner_path, return_value=mock.MagicMock(spec=UnifiDeviceScanner)) async def test_get_scanner(unifi_mock, hass): """Test creating an Unifi direct scanner with a password.""" conf_dict = { diff --git a/tests/ignore_uncaught_exceptions.py b/tests/ignore_uncaught_exceptions.py index f4720db25ee..ee256acbbc6 100644 --- a/tests/ignore_uncaught_exceptions.py +++ b/tests/ignore_uncaught_exceptions.py @@ -1,11 +1,6 @@ """List of modules that have uncaught exceptions today. Will be shrunk over time.""" IGNORE_UNCAUGHT_EXCEPTIONS = [ - ("tests.components.cast.test_media_player", "test_start_discovery_called_once"), - ("tests.components.cast.test_media_player", "test_entry_setup_single_config"), - ("tests.components.cast.test_media_player", "test_entry_setup_list_config"), - ("tests.components.cast.test_media_player", "test_entry_setup_platform_not_ready"), ("tests.components.demo.test_init", "test_setting_up_demo"), - ("tests.components.discovery.test_init", "test_discover_config_flow"), ("tests.components.dyson.test_air_quality", "test_purecool_aiq_attributes"), ("tests.components.dyson.test_air_quality", "test_purecool_aiq_update_state"), ( @@ -42,18 +37,6 @@ IGNORE_UNCAUGHT_EXCEPTIONS = [ ("tests.components.qwikswitch.test_init", "test_binary_sensor_device"), ("tests.components.qwikswitch.test_init", "test_sensor_device"), ("tests.components.rflink.test_init", "test_send_command_invalid_arguments"), - ("tests.components.unifi_direct.test_device_tracker", "test_get_scanner"), ] -IGNORE_UNCAUGHT_JSON_EXCEPTIONS = [ - ("tests.components.spotify.test_config_flow", "test_full_flow"), - ("tests.components.smartthings.test_init", "test_config_entry_loads_platforms"), - ( - "tests.components.smartthings.test_init", - "test_scenes_unauthorized_loads_platforms", - ), - ( - "tests.components.smartthings.test_init", - "test_config_entry_loads_unconnected_cloud", - ), -] +IGNORE_UNCAUGHT_JSON_EXCEPTIONS = []