Use platform enums in vizio tests (#62555)

This commit is contained in:
Robert Hillis 2021-12-22 07:33:13 -05:00 committed by GitHub
parent d9788c2447
commit 432d48a4d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,9 +3,8 @@ from datetime import timedelta
import pytest import pytest
from homeassistant.components.media_player.const import DOMAIN as MP_DOMAIN
from homeassistant.components.vizio.const import DOMAIN from homeassistant.components.vizio.const import DOMAIN
from homeassistant.const import STATE_UNAVAILABLE from homeassistant.const import STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -25,7 +24,7 @@ async def test_setup_component(
hass, DOMAIN, {DOMAIN: MOCK_USER_VALID_TV_CONFIG} hass, DOMAIN, {DOMAIN: MOCK_USER_VALID_TV_CONFIG}
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(hass.states.async_entity_ids(MP_DOMAIN)) == 1 assert len(hass.states.async_entity_ids(Platform.MEDIA_PLAYER)) == 1
async def test_tv_load_and_unload( async def test_tv_load_and_unload(
@ -40,12 +39,12 @@ async def test_tv_load_and_unload(
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(hass.states.async_entity_ids(MP_DOMAIN)) == 1 assert len(hass.states.async_entity_ids(Platform.MEDIA_PLAYER)) == 1
assert DOMAIN in hass.data assert DOMAIN in hass.data
assert await config_entry.async_unload(hass) assert await config_entry.async_unload(hass)
await hass.async_block_till_done() await hass.async_block_till_done()
entities = hass.states.async_entity_ids(MP_DOMAIN) entities = hass.states.async_entity_ids(Platform.MEDIA_PLAYER)
assert len(entities) == 1 assert len(entities) == 1
for entity in entities: for entity in entities:
assert hass.states.get(entity).state == STATE_UNAVAILABLE assert hass.states.get(entity).state == STATE_UNAVAILABLE
@ -64,12 +63,12 @@ async def test_speaker_load_and_unload(
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(hass.states.async_entity_ids(MP_DOMAIN)) == 1 assert len(hass.states.async_entity_ids(Platform.MEDIA_PLAYER)) == 1
assert DOMAIN in hass.data assert DOMAIN in hass.data
assert await config_entry.async_unload(hass) assert await config_entry.async_unload(hass)
await hass.async_block_till_done() await hass.async_block_till_done()
entities = hass.states.async_entity_ids(MP_DOMAIN) entities = hass.states.async_entity_ids(Platform.MEDIA_PLAYER)
assert len(entities) == 1 assert len(entities) == 1
for entity in entities: for entity in entities:
assert hass.states.get(entity).state == STATE_UNAVAILABLE assert hass.states.get(entity).state == STATE_UNAVAILABLE
@ -91,7 +90,7 @@ async def test_coordinator_update_failure(
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(hass.states.async_entity_ids(MP_DOMAIN)) == 1 assert len(hass.states.async_entity_ids(Platform.MEDIA_PLAYER)) == 1
assert DOMAIN in hass.data assert DOMAIN in hass.data
# Failing 25 days in a row should result in a single log message # Failing 25 days in a row should result in a single log message