Update vizio dependency and integration name (#31975)

* bump pyvizio version and clean up code

* fix requirements

* update parameter to optional per review in docs PR
This commit is contained in:
Raman Gupta authored and GitHub committed 2020-02-20 08:43:29 -08:00
1 parent 51b2d0b4f8
commit 7a6b13cb0d
10 files changed
+46 -27

No files matched your search

+4 -4
View File
@@ -53,7 +53,7 @@ def vizio_bypass_setup_fixture():
def vizio_bypass_update_fixture():
"""Mock component update."""
with patch(
"homeassistant.components.vizio.media_player.VizioAsync.can_connect",
"homeassistant.components.vizio.media_player.VizioAsync.can_connect_with_auth_check",
return_value=True,
), patch("homeassistant.components.vizio.media_player.VizioDevice.async_update"):
yield
@@ -71,7 +71,7 @@ def vizio_guess_device_type_fixture():
@pytest.fixture(name="vizio_cant_connect")
def vizio_cant_connect_fixture():
"""Mock vizio device can't connect."""
"""Mock vizio device can't connect with valid auth."""
with patch(
"homeassistant.components.vizio.config_flow.VizioAsync.validate_ha_config",
return_value=False,
@@ -83,7 +83,7 @@ def vizio_cant_connect_fixture():
def vizio_update_fixture():
"""Mock valid updates to vizio device."""
with patch(
"homeassistant.components.vizio.media_player.VizioAsync.can_connect",
"homeassistant.components.vizio.media_player.VizioAsync.can_connect_with_auth_check",
return_value=True,
), patch(
"homeassistant.components.vizio.media_player.VizioAsync.get_current_volume",
@@ -98,7 +98,7 @@ def vizio_update_fixture():
"homeassistant.components.vizio.media_player.VizioAsync.get_power_state",
return_value=True,
), patch(
"homeassistant.components.vizio.media_player.VizioAsync.get_model",
"homeassistant.components.vizio.media_player.VizioAsync.get_model_name",
return_value=MODEL,
), patch(
"homeassistant.components.vizio.media_player.VizioAsync.get_version",
+1 -1
View File
@@ -48,7 +48,7 @@ MOCK_IMPORT_VALID_TV_CONFIG = {
CONF_VOLUME_STEP: VOLUME_STEP,
}
MOCK_INVALID_TV_CONFIG = {
MOCK_TV_CONFIG_NO_TOKEN = {
CONF_NAME: NAME,
CONF_HOST: HOST,
CONF_DEVICE_CLASS: DEVICE_CLASS_TV,
+2 -2
View File
@@ -25,8 +25,8 @@ from .const import (
HOST,
HOST2,
MOCK_IMPORT_VALID_TV_CONFIG,
MOCK_INVALID_TV_CONFIG,
MOCK_SPEAKER_CONFIG,
MOCK_TV_CONFIG_NO_TOKEN,
MOCK_USER_VALID_TV_CONFIG,
MOCK_ZEROCONF_SERVICE_INFO,
NAME,
@@ -219,7 +219,7 @@ async def test_user_error_on_tv_needs_token(
) -> None:
"""Test when config fails custom validation for non null access token when device_class = tv during user setup."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_INVALID_TV_CONFIG
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_TV_CONFIG_NO_TOKEN
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
+25 -9
View File
@@ -97,7 +97,7 @@ async def _test_setup(
async def _test_setup_failure(hass: HomeAssistantType, config: str) -> None:
"""Test generic Vizio entity setup failure."""
with patch(
"homeassistant.components.vizio.media_player.VizioAsync.can_connect",
"homeassistant.components.vizio.media_player.VizioAsync.can_connect_with_auth_check",
return_value=False,
):
config_entry = MockConfigEntry(domain=DOMAIN, data=config, unique_id=UNIQUE_ID)
@@ -133,42 +133,54 @@ async def _test_service(
async def test_speaker_on(
hass: HomeAssistantType, vizio_connect: pytest.fixture, vizio_update: pytest.fixture
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test Vizio Speaker entity setup when on."""
await _test_setup(hass, DEVICE_CLASS_SPEAKER, True)
async def test_speaker_off(
hass: HomeAssistantType, vizio_connect: pytest.fixture, vizio_update: pytest.fixture
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test Vizio Speaker entity setup when off."""
await _test_setup(hass, DEVICE_CLASS_SPEAKER, False)
async def test_speaker_unavailable(
hass: HomeAssistantType, vizio_connect: pytest.fixture, vizio_update: pytest.fixture
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test Vizio Speaker entity setup when unavailable."""
await _test_setup(hass, DEVICE_CLASS_SPEAKER, None)
async def test_init_tv_on(
hass: HomeAssistantType, vizio_connect: pytest.fixture, vizio_update: pytest.fixture
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test Vizio TV entity setup when on."""
await _test_setup(hass, DEVICE_CLASS_TV, True)
async def test_init_tv_off(
hass: HomeAssistantType, vizio_connect: pytest.fixture, vizio_update: pytest.fixture
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test Vizio TV entity setup when off."""
await _test_setup(hass, DEVICE_CLASS_TV, False)
async def test_init_tv_unavailable(
hass: HomeAssistantType, vizio_connect: pytest.fixture, vizio_update: pytest.fixture
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test Vizio TV entity setup when unavailable."""
await _test_setup(hass, DEVICE_CLASS_TV, None)
@@ -189,7 +201,9 @@ async def test_setup_failure_tv(
async def test_services(
hass: HomeAssistantType, vizio_connect: pytest.fixture, vizio_update: pytest.fixture
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test all Vizio media player entity services."""
await _test_setup(hass, DEVICE_CLASS_TV, True)
@@ -218,7 +232,9 @@ async def test_services(
async def test_options_update(
hass: HomeAssistantType, vizio_connect: pytest.fixture, vizio_update: pytest.fixture
hass: HomeAssistantType,
vizio_connect: pytest.fixture,
vizio_update: pytest.fixture,
) -> None:
"""Test when config entry update event fires."""
await _test_setup(hass, DEVICE_CLASS_SPEAKER, True)