diff --git a/tests/components/vizio/const.py b/tests/components/vizio/const.py index e39864a6157..119443962fc 100644 --- a/tests/components/vizio/const.py +++ b/tests/components/vizio/const.py @@ -1,9 +1,8 @@ """Constants for the Vizio integration tests.""" from homeassistant.components import zeroconf from homeassistant.components.media_player import ( - DEVICE_CLASS_SPEAKER, - DEVICE_CLASS_TV, DOMAIN as MP_DOMAIN, + MediaPlayerDeviceClass, ) from homeassistant.components.vizio.const import ( CONF_ADDITIONAL_CONFIGS, @@ -102,7 +101,7 @@ MOCK_PIN_CONFIG = {CONF_PIN: PIN} MOCK_USER_VALID_TV_CONFIG = { CONF_NAME: NAME, CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_TV, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.TV, CONF_ACCESS_TOKEN: ACCESS_TOKEN, } @@ -113,7 +112,7 @@ MOCK_OPTIONS = { MOCK_IMPORT_VALID_TV_CONFIG = { CONF_NAME: NAME, CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_TV, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.TV, CONF_ACCESS_TOKEN: ACCESS_TOKEN, CONF_VOLUME_STEP: VOLUME_STEP, } @@ -121,7 +120,7 @@ MOCK_IMPORT_VALID_TV_CONFIG = { MOCK_TV_WITH_INCLUDE_CONFIG = { CONF_NAME: NAME, CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_TV, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.TV, CONF_ACCESS_TOKEN: ACCESS_TOKEN, CONF_VOLUME_STEP: VOLUME_STEP, CONF_APPS: {CONF_INCLUDE: [CURRENT_APP]}, @@ -130,7 +129,7 @@ MOCK_TV_WITH_INCLUDE_CONFIG = { MOCK_TV_WITH_EXCLUDE_CONFIG = { CONF_NAME: NAME, CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_TV, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.TV, CONF_ACCESS_TOKEN: ACCESS_TOKEN, CONF_VOLUME_STEP: VOLUME_STEP, CONF_APPS: {CONF_EXCLUDE: ["Netflix"]}, @@ -139,7 +138,7 @@ MOCK_TV_WITH_EXCLUDE_CONFIG = { MOCK_TV_WITH_ADDITIONAL_APPS_CONFIG = { CONF_NAME: NAME, CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_TV, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.TV, CONF_ACCESS_TOKEN: ACCESS_TOKEN, CONF_VOLUME_STEP: VOLUME_STEP, CONF_APPS: {CONF_ADDITIONAL_CONFIGS: [ADDITIONAL_APP_CONFIG]}, @@ -148,7 +147,7 @@ MOCK_TV_WITH_ADDITIONAL_APPS_CONFIG = { MOCK_SPEAKER_APPS_FAILURE = { CONF_NAME: NAME, CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_SPEAKER, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.SPEAKER, CONF_ACCESS_TOKEN: ACCESS_TOKEN, CONF_VOLUME_STEP: VOLUME_STEP, CONF_APPS: {CONF_ADDITIONAL_CONFIGS: [ADDITIONAL_APP_CONFIG]}, @@ -157,7 +156,7 @@ MOCK_SPEAKER_APPS_FAILURE = { MOCK_TV_APPS_FAILURE = { CONF_NAME: NAME, CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_TV, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.TV, CONF_ACCESS_TOKEN: ACCESS_TOKEN, CONF_VOLUME_STEP: VOLUME_STEP, CONF_APPS: None, @@ -165,7 +164,7 @@ MOCK_TV_APPS_FAILURE = { MOCK_TV_APPS_WITH_VALID_APPS_CONFIG = { CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_TV, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.TV, CONF_ACCESS_TOKEN: ACCESS_TOKEN, CONF_APPS: {CONF_INCLUDE: [CURRENT_APP]}, } @@ -173,13 +172,13 @@ MOCK_TV_APPS_WITH_VALID_APPS_CONFIG = { MOCK_TV_CONFIG_NO_TOKEN = { CONF_NAME: NAME, CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_TV, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.TV, } MOCK_SPEAKER_CONFIG = { CONF_NAME: NAME, CONF_HOST: HOST, - CONF_DEVICE_CLASS: DEVICE_CLASS_SPEAKER, + CONF_DEVICE_CLASS: MediaPlayerDeviceClass.SPEAKER, } MOCK_INCLUDE_APPS = { diff --git a/tests/components/vizio/test_config_flow.py b/tests/components/vizio/test_config_flow.py index 817f23d52c5..3250163ef8e 100644 --- a/tests/components/vizio/test_config_flow.py +++ b/tests/components/vizio/test_config_flow.py @@ -5,7 +5,7 @@ import pytest import voluptuous as vol from homeassistant import data_entry_flow -from homeassistant.components.media_player import DEVICE_CLASS_SPEAKER, DEVICE_CLASS_TV +from homeassistant.components.media_player import MediaPlayerDeviceClass from homeassistant.components.vizio.config_flow import _get_config_schema from homeassistant.components.vizio.const import ( CONF_APPS, @@ -77,7 +77,7 @@ async def test_user_flow_minimum_fields( assert result["title"] == NAME assert result["data"][CONF_NAME] == NAME assert result["data"][CONF_HOST] == HOST - assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_SPEAKER + assert result["data"][CONF_DEVICE_CLASS] == MediaPlayerDeviceClass.SPEAKER async def test_user_flow_all_fields( @@ -102,7 +102,7 @@ async def test_user_flow_all_fields( assert result["title"] == NAME assert result["data"][CONF_NAME] == NAME assert result["data"][CONF_HOST] == HOST - assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_TV + assert result["data"][CONF_DEVICE_CLASS] == MediaPlayerDeviceClass.TV assert result["data"][CONF_ACCESS_TOKEN] == ACCESS_TOKEN assert CONF_APPS not in result["data"] @@ -339,7 +339,7 @@ async def test_user_tv_pairing_no_apps( assert result["title"] == NAME assert result["data"][CONF_NAME] == NAME assert result["data"][CONF_HOST] == HOST - assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_TV + assert result["data"][CONF_DEVICE_CLASS] == MediaPlayerDeviceClass.TV assert CONF_APPS not in result["data"] @@ -412,7 +412,7 @@ async def test_import_flow_minimum_fields( DOMAIN, context={"source": SOURCE_IMPORT}, data=vol.Schema(VIZIO_SCHEMA)( - {CONF_HOST: HOST, CONF_DEVICE_CLASS: DEVICE_CLASS_SPEAKER} + {CONF_HOST: HOST, CONF_DEVICE_CLASS: MediaPlayerDeviceClass.SPEAKER} ), ) @@ -420,7 +420,7 @@ async def test_import_flow_minimum_fields( assert result["title"] == DEFAULT_NAME assert result["data"][CONF_NAME] == DEFAULT_NAME assert result["data"][CONF_HOST] == HOST - assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_SPEAKER + assert result["data"][CONF_DEVICE_CLASS] == MediaPlayerDeviceClass.SPEAKER assert result["data"][CONF_VOLUME_STEP] == DEFAULT_VOLUME_STEP @@ -440,7 +440,7 @@ async def test_import_flow_all_fields( assert result["title"] == NAME assert result["data"][CONF_NAME] == NAME assert result["data"][CONF_HOST] == HOST - assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_TV + assert result["data"][CONF_DEVICE_CLASS] == MediaPlayerDeviceClass.TV assert result["data"][CONF_ACCESS_TOKEN] == ACCESS_TOKEN assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP @@ -599,7 +599,7 @@ async def test_import_needs_pairing( assert result["title"] == NAME assert result["data"][CONF_NAME] == NAME assert result["data"][CONF_HOST] == HOST - assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_TV + assert result["data"][CONF_DEVICE_CLASS] == MediaPlayerDeviceClass.TV async def test_import_with_apps_needs_pairing( @@ -641,7 +641,7 @@ async def test_import_with_apps_needs_pairing( assert result["title"] == NAME assert result["data"][CONF_NAME] == NAME assert result["data"][CONF_HOST] == HOST - assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_TV + assert result["data"][CONF_DEVICE_CLASS] == MediaPlayerDeviceClass.TV assert result["data"][CONF_APPS][CONF_INCLUDE] == [CURRENT_APP] @@ -756,7 +756,7 @@ async def test_zeroconf_flow( assert result["title"] == NAME assert result["data"][CONF_HOST] == HOST assert result["data"][CONF_NAME] == NAME - assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_SPEAKER + assert result["data"][CONF_DEVICE_CLASS] == MediaPlayerDeviceClass.SPEAKER async def test_zeroconf_flow_already_configured( diff --git a/tests/components/vizio/test_media_player.py b/tests/components/vizio/test_media_player.py index 80f72280951..1c637733927 100644 --- a/tests/components/vizio/test_media_player.py +++ b/tests/components/vizio/test_media_player.py @@ -24,8 +24,6 @@ from homeassistant.components.media_player import ( ATTR_MEDIA_VOLUME_LEVEL, ATTR_MEDIA_VOLUME_MUTED, ATTR_SOUND_MODE, - DEVICE_CLASS_SPEAKER, - DEVICE_CLASS_TV, DOMAIN as MP_DOMAIN, SERVICE_MEDIA_NEXT_TRACK, SERVICE_MEDIA_PREVIOUS_TRACK, @@ -37,6 +35,7 @@ from homeassistant.components.media_player import ( SERVICE_VOLUME_MUTE, SERVICE_VOLUME_SET, SERVICE_VOLUME_UP, + MediaPlayerDeviceClass, ) from homeassistant.components.media_player.const import ATTR_INPUT_SOURCE_LIST from homeassistant.components.vizio import validate_apps @@ -158,7 +157,9 @@ async def _test_setup_tv(hass: HomeAssistant, vizio_power_state: bool | None) -> ): await _add_config_entry_to_hass(hass, config_entry) - attr = _get_attr_and_assert_base_attr(hass, DEVICE_CLASS_TV, ha_power_state) + attr = _get_attr_and_assert_base_attr( + hass, MediaPlayerDeviceClass.TV, ha_power_state + ) if ha_power_state == STATE_ON: _assert_sources_and_volume(attr, VIZIO_DEVICE_CLASS_TV) assert "sound_mode" not in attr @@ -192,7 +193,7 @@ async def _test_setup_speaker( await _add_config_entry_to_hass(hass, config_entry) attr = _get_attr_and_assert_base_attr( - hass, DEVICE_CLASS_SPEAKER, ha_power_state + hass, MediaPlayerDeviceClass.SPEAKER, ha_power_state ) if ha_power_state == STATE_ON: _assert_sources_and_volume(attr, VIZIO_DEVICE_CLASS_SPEAKER) @@ -219,7 +220,9 @@ async def _cm_for_test_setup_tv_with_apps( ): await _add_config_entry_to_hass(hass, config_entry) - attr = _get_attr_and_assert_base_attr(hass, DEVICE_CLASS_TV, STATE_ON) + attr = _get_attr_and_assert_base_attr( + hass, MediaPlayerDeviceClass.TV, STATE_ON + ) assert ( attr["volume_level"] == float(int(MAX_VOLUME[VIZIO_DEVICE_CLASS_TV] / 2)) @@ -714,7 +717,7 @@ async def test_setup_tv_without_mute( ): await _add_config_entry_to_hass(hass, config_entry) - attr = _get_attr_and_assert_base_attr(hass, DEVICE_CLASS_TV, STATE_ON) + attr = _get_attr_and_assert_base_attr(hass, MediaPlayerDeviceClass.TV, STATE_ON) _assert_sources_and_volume(attr, VIZIO_DEVICE_CLASS_TV) assert "sound_mode" not in attr assert "is_volume_muted" not in attr @@ -763,6 +766,6 @@ async def test_vizio_update_with_apps_on_input( unique_id=UNIQUE_ID, ) await _add_config_entry_to_hass(hass, config_entry) - attr = _get_attr_and_assert_base_attr(hass, DEVICE_CLASS_TV, STATE_ON) + attr = _get_attr_and_assert_base_attr(hass, MediaPlayerDeviceClass.TV, STATE_ON) # app ID should not be in the attributes assert "app_id" not in attr