Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
"""Tests for Vizio config flow."""
|
2020-02-28 06:04:59 +00:00
|
|
|
import logging
|
|
|
|
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
import pytest
|
|
|
|
import voluptuous as vol
|
|
|
|
|
|
|
|
from homeassistant import data_entry_flow
|
2020-01-18 08:15:06 +00:00
|
|
|
from homeassistant.components.media_player import DEVICE_CLASS_SPEAKER, DEVICE_CLASS_TV
|
2020-03-05 21:34:12 +00:00
|
|
|
from homeassistant.components.vizio.config_flow import _get_config_schema
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
from homeassistant.components.vizio.const import (
|
2020-03-05 21:34:12 +00:00
|
|
|
CONF_APPS,
|
2020-04-09 03:44:33 +00:00
|
|
|
CONF_APPS_TO_INCLUDE_OR_EXCLUDE,
|
2020-03-05 21:34:12 +00:00
|
|
|
CONF_INCLUDE,
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
CONF_VOLUME_STEP,
|
|
|
|
DEFAULT_NAME,
|
|
|
|
DEFAULT_VOLUME_STEP,
|
|
|
|
DOMAIN,
|
2020-01-18 08:15:06 +00:00
|
|
|
VIZIO_SCHEMA,
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
2020-04-16 21:53:34 +00:00
|
|
|
from homeassistant.config_entries import (
|
|
|
|
SOURCE_IGNORE,
|
|
|
|
SOURCE_IMPORT,
|
|
|
|
SOURCE_USER,
|
|
|
|
SOURCE_ZEROCONF,
|
|
|
|
)
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
from homeassistant.const import (
|
|
|
|
CONF_ACCESS_TOKEN,
|
|
|
|
CONF_DEVICE_CLASS,
|
|
|
|
CONF_HOST,
|
|
|
|
CONF_NAME,
|
2020-02-28 06:04:59 +00:00
|
|
|
CONF_PIN,
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
from homeassistant.helpers.typing import HomeAssistantType
|
|
|
|
|
2020-01-30 21:13:45 +00:00
|
|
|
from .const import (
|
|
|
|
ACCESS_TOKEN,
|
2020-03-05 21:34:12 +00:00
|
|
|
CURRENT_APP,
|
2020-01-30 21:13:45 +00:00
|
|
|
HOST,
|
|
|
|
HOST2,
|
|
|
|
MOCK_IMPORT_VALID_TV_CONFIG,
|
2020-03-05 21:34:12 +00:00
|
|
|
MOCK_INCLUDE_APPS,
|
|
|
|
MOCK_INCLUDE_NO_APPS,
|
2020-02-28 06:04:59 +00:00
|
|
|
MOCK_PIN_CONFIG,
|
2020-01-30 21:13:45 +00:00
|
|
|
MOCK_SPEAKER_CONFIG,
|
2020-02-20 16:43:29 +00:00
|
|
|
MOCK_TV_CONFIG_NO_TOKEN,
|
2020-03-13 11:16:24 +00:00
|
|
|
MOCK_TV_WITH_ADDITIONAL_APPS_CONFIG,
|
2020-03-05 21:34:12 +00:00
|
|
|
MOCK_TV_WITH_EXCLUDE_CONFIG,
|
2020-01-30 21:13:45 +00:00
|
|
|
MOCK_USER_VALID_TV_CONFIG,
|
|
|
|
MOCK_ZEROCONF_SERVICE_INFO,
|
|
|
|
NAME,
|
|
|
|
NAME2,
|
|
|
|
UNIQUE_ID,
|
|
|
|
VOLUME_STEP,
|
|
|
|
)
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
|
2020-01-30 21:13:45 +00:00
|
|
|
from tests.common import MockConfigEntry
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
|
2020-02-28 06:04:59 +00:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
|
2020-01-20 04:13:15 +00:00
|
|
|
async def test_user_flow_minimum_fields(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
2020-01-20 04:13:15 +00:00
|
|
|
) -> None:
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
"""Test user config flow with minimum fields."""
|
|
|
|
# test form shows
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-01-20 04:13:15 +00:00
|
|
|
DOMAIN, context={"source": SOURCE_USER}
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "user"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
2020-01-30 21:13:45 +00:00
|
|
|
result["flow_id"], user_input=MOCK_SPEAKER_CONFIG
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
assert result["title"] == NAME
|
|
|
|
assert result["data"][CONF_NAME] == NAME
|
|
|
|
assert result["data"][CONF_HOST] == HOST
|
2020-01-18 08:15:06 +00:00
|
|
|
assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_SPEAKER
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
|
|
|
|
|
2020-01-20 04:13:15 +00:00
|
|
|
async def test_user_flow_all_fields(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
2020-01-20 04:13:15 +00:00
|
|
|
) -> None:
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
"""Test user config flow with all fields."""
|
|
|
|
# test form shows
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-01-20 04:13:15 +00:00
|
|
|
DOMAIN, context={"source": SOURCE_USER}
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "user"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
2020-01-30 21:13:45 +00:00
|
|
|
result["flow_id"], user_input=MOCK_USER_VALID_TV_CONFIG
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
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_ACCESS_TOKEN] == ACCESS_TOKEN
|
2020-03-13 11:16:24 +00:00
|
|
|
assert CONF_APPS not in result["data"]
|
2020-03-05 21:34:12 +00:00
|
|
|
|
|
|
|
|
2020-03-13 11:16:24 +00:00
|
|
|
async def test_speaker_options_flow(hass: HomeAssistantType) -> None:
|
|
|
|
"""Test options config flow for speaker."""
|
|
|
|
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_SPEAKER_CONFIG)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
assert not entry.options
|
|
|
|
|
|
|
|
result = await hass.config_entries.options.async_init(entry.entry_id, data=None)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "init"
|
|
|
|
|
|
|
|
result = await hass.config_entries.options.async_configure(
|
|
|
|
result["flow_id"], user_input={CONF_VOLUME_STEP: VOLUME_STEP}
|
2020-03-05 21:34:12 +00:00
|
|
|
)
|
|
|
|
|
2020-03-13 11:16:24 +00:00
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
assert result["title"] == ""
|
|
|
|
assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP
|
|
|
|
assert CONF_APPS not in result["data"]
|
|
|
|
|
|
|
|
|
|
|
|
async def test_tv_options_flow_no_apps(hass: HomeAssistantType) -> None:
|
|
|
|
"""Test options config flow for TV without providing apps option."""
|
|
|
|
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_VALID_TV_CONFIG)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
assert not entry.options
|
|
|
|
|
|
|
|
result = await hass.config_entries.options.async_init(entry.entry_id, data=None)
|
|
|
|
|
2020-03-05 21:34:12 +00:00
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
2020-03-13 11:16:24 +00:00
|
|
|
assert result["step_id"] == "init"
|
2020-03-05 21:34:12 +00:00
|
|
|
|
2020-03-13 11:16:24 +00:00
|
|
|
options = {CONF_VOLUME_STEP: VOLUME_STEP}
|
|
|
|
options.update(MOCK_INCLUDE_NO_APPS)
|
|
|
|
|
|
|
|
result = await hass.config_entries.options.async_configure(
|
|
|
|
result["flow_id"], user_input=options
|
2020-03-05 21:34:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
2020-03-13 11:16:24 +00:00
|
|
|
assert result["title"] == ""
|
|
|
|
assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP
|
|
|
|
assert CONF_APPS not in result["data"]
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
|
|
|
|
|
2020-03-13 11:16:24 +00:00
|
|
|
async def test_tv_options_flow_with_apps(hass: HomeAssistantType) -> None:
|
|
|
|
"""Test options config flow for TV with providing apps option."""
|
|
|
|
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_VALID_TV_CONFIG)
|
2020-01-18 08:15:06 +00:00
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
assert not entry.options
|
|
|
|
|
2020-01-23 00:55:34 +00:00
|
|
|
result = await hass.config_entries.options.async_init(entry.entry_id, data=None)
|
2020-01-18 08:15:06 +00:00
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
2020-04-09 03:44:33 +00:00
|
|
|
assert result["step_id"] == "init"
|
|
|
|
|
|
|
|
options = {CONF_VOLUME_STEP: VOLUME_STEP}
|
|
|
|
options.update(MOCK_INCLUDE_APPS)
|
|
|
|
|
|
|
|
result = await hass.config_entries.options.async_configure(
|
|
|
|
result["flow_id"], user_input=options
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
assert result["title"] == ""
|
|
|
|
assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP
|
|
|
|
assert CONF_APPS in result["data"]
|
|
|
|
assert result["data"][CONF_APPS] == {CONF_INCLUDE: [CURRENT_APP]}
|
|
|
|
|
|
|
|
|
|
|
|
async def test_tv_options_flow_start_with_volume(hass: HomeAssistantType) -> None:
|
|
|
|
"""Test options config flow for TV with providing apps option after providing volume step in initial config."""
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
|
|
|
data=MOCK_USER_VALID_TV_CONFIG,
|
|
|
|
options={CONF_VOLUME_STEP: VOLUME_STEP},
|
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
assert entry.options
|
|
|
|
assert entry.options == {CONF_VOLUME_STEP: VOLUME_STEP}
|
|
|
|
assert CONF_APPS not in entry.options
|
|
|
|
assert CONF_APPS_TO_INCLUDE_OR_EXCLUDE not in entry.options
|
|
|
|
|
|
|
|
result = await hass.config_entries.options.async_init(entry.entry_id, data=None)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
2020-01-18 08:15:06 +00:00
|
|
|
assert result["step_id"] == "init"
|
|
|
|
|
2020-03-13 11:16:24 +00:00
|
|
|
options = {CONF_VOLUME_STEP: VOLUME_STEP}
|
|
|
|
options.update(MOCK_INCLUDE_APPS)
|
|
|
|
|
2020-01-18 08:15:06 +00:00
|
|
|
result = await hass.config_entries.options.async_configure(
|
2020-03-13 11:16:24 +00:00
|
|
|
result["flow_id"], user_input=options
|
2020-01-18 08:15:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
assert result["title"] == ""
|
|
|
|
assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP
|
2020-03-13 11:16:24 +00:00
|
|
|
assert CONF_APPS in result["data"]
|
|
|
|
assert result["data"][CONF_APPS] == {CONF_INCLUDE: [CURRENT_APP]}
|
2020-01-18 08:15:06 +00:00
|
|
|
|
|
|
|
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
async def test_user_host_already_configured(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test host is already configured during user setup."""
|
|
|
|
entry = MockConfigEntry(
|
2020-01-22 09:13:35 +00:00
|
|
|
domain=DOMAIN, data=MOCK_SPEAKER_CONFIG, options={CONF_VOLUME_STEP: VOLUME_STEP}
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
2020-01-18 08:15:06 +00:00
|
|
|
fail_entry = MOCK_SPEAKER_CONFIG.copy()
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
fail_entry[CONF_NAME] = "newtestname"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-01-23 00:55:34 +00:00
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data=fail_entry
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["errors"] == {CONF_HOST: "host_exists"}
|
|
|
|
|
|
|
|
|
2020-02-04 19:31:03 +00:00
|
|
|
async def test_user_host_already_configured_no_port(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test host is already configured during user setup when existing entry has no port."""
|
|
|
|
# Mock entry without port so we can test that the same entry WITH a port will fail
|
|
|
|
no_port_entry = MOCK_SPEAKER_CONFIG.copy()
|
|
|
|
no_port_entry[CONF_HOST] = no_port_entry[CONF_HOST].split(":")[0]
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN, data=no_port_entry, options={CONF_VOLUME_STEP: VOLUME_STEP}
|
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
fail_entry = MOCK_SPEAKER_CONFIG.copy()
|
|
|
|
fail_entry[CONF_NAME] = "newtestname"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data=fail_entry
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["errors"] == {CONF_HOST: "host_exists"}
|
|
|
|
|
|
|
|
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
async def test_user_name_already_configured(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test name is already configured during user setup."""
|
|
|
|
entry = MockConfigEntry(
|
2020-01-22 09:13:35 +00:00
|
|
|
domain=DOMAIN, data=MOCK_SPEAKER_CONFIG, options={CONF_VOLUME_STEP: VOLUME_STEP}
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
2020-01-18 08:15:06 +00:00
|
|
|
fail_entry = MOCK_SPEAKER_CONFIG.copy()
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
fail_entry[CONF_HOST] = "0.0.0.0"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-01-23 00:55:34 +00:00
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data=fail_entry
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["errors"] == {CONF_NAME: "name_exists"}
|
|
|
|
|
|
|
|
|
2020-01-20 04:13:15 +00:00
|
|
|
async def test_user_esn_already_exists(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
2020-01-20 04:13:15 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test ESN is already configured with different host and name during user setup."""
|
|
|
|
# Set up new entry
|
|
|
|
MockConfigEntry(
|
|
|
|
domain=DOMAIN, data=MOCK_SPEAKER_CONFIG, unique_id=UNIQUE_ID
|
|
|
|
).add_to_hass(hass)
|
|
|
|
|
|
|
|
# Set up new entry with same unique_id but different host and name
|
|
|
|
fail_entry = MOCK_SPEAKER_CONFIG.copy()
|
|
|
|
fail_entry[CONF_HOST] = HOST2
|
|
|
|
fail_entry[CONF_NAME] = NAME2
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data=fail_entry
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
2020-02-28 06:04:59 +00:00
|
|
|
assert result["reason"] == "already_configured"
|
2020-01-20 04:13:15 +00:00
|
|
|
|
|
|
|
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
async def test_user_error_on_could_not_connect(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType, vizio_cant_connect: pytest.fixture
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test with could_not_connect during user_setup."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-01-23 00:55:34 +00:00
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_USER_VALID_TV_CONFIG
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["errors"] == {"base": "cant_connect"}
|
|
|
|
|
|
|
|
|
2020-03-05 21:34:12 +00:00
|
|
|
async def test_user_tv_pairing_no_apps(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
2020-02-28 06:04:59 +00:00
|
|
|
vizio_complete_pairing: pytest.fixture,
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
) -> None:
|
2020-03-05 21:34:12 +00:00
|
|
|
"""Test pairing config flow when access token not provided for tv during user entry and no apps configured."""
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-02-20 16:43:29 +00:00
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_TV_CONFIG_NO_TOKEN
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
2020-02-28 06:04:59 +00:00
|
|
|
assert result["step_id"] == "pair_tv"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=MOCK_PIN_CONFIG
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
2020-03-13 11:16:24 +00:00
|
|
|
assert result["step_id"] == "pairing_complete"
|
2020-02-28 06:04:59 +00:00
|
|
|
|
2020-03-13 11:16:24 +00:00
|
|
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
2020-02-28 06:04:59 +00:00
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
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
|
2020-03-05 21:34:12 +00:00
|
|
|
assert CONF_APPS not in result["data"]
|
2020-02-28 06:04:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_user_start_pairing_failure(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
vizio_start_pairing_failure: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test failure to start pairing from user config flow."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_TV_CONFIG_NO_TOKEN
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "user"
|
|
|
|
assert result["errors"] == {"base": "cant_connect"}
|
|
|
|
|
|
|
|
|
|
|
|
async def test_user_invalid_pin(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
vizio_invalid_pin_failure: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test failure to complete pairing from user config flow."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_TV_CONFIG_NO_TOKEN
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "pair_tv"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=MOCK_PIN_CONFIG
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "pair_tv"
|
|
|
|
assert result["errors"] == {CONF_PIN: "complete_pairing_failed"}
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
|
|
|
|
|
2020-04-16 21:53:34 +00:00
|
|
|
async def test_user_ignore(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test user config flow doesn't throw an error when there's an existing ignored source."""
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
|
|
|
data=MOCK_SPEAKER_CONFIG,
|
|
|
|
options={CONF_VOLUME_STEP: VOLUME_STEP},
|
|
|
|
source=SOURCE_IGNORE,
|
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_SPEAKER_CONFIG
|
|
|
|
)
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
|
|
|
|
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
async def test_import_flow_minimum_fields(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test import config flow with minimum fields."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
2020-01-23 00:55:34 +00:00
|
|
|
context={"source": SOURCE_IMPORT},
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(
|
2020-01-18 08:15:06 +00:00
|
|
|
{CONF_HOST: HOST, CONF_DEVICE_CLASS: DEVICE_CLASS_SPEAKER}
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
assert result["title"] == DEFAULT_NAME
|
|
|
|
assert result["data"][CONF_NAME] == DEFAULT_NAME
|
|
|
|
assert result["data"][CONF_HOST] == HOST
|
2020-01-18 08:15:06 +00:00
|
|
|
assert result["data"][CONF_DEVICE_CLASS] == DEVICE_CLASS_SPEAKER
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
assert result["data"][CONF_VOLUME_STEP] == DEFAULT_VOLUME_STEP
|
|
|
|
|
|
|
|
|
2020-01-20 04:13:15 +00:00
|
|
|
async def test_import_flow_all_fields(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
2020-01-20 04:13:15 +00:00
|
|
|
) -> None:
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
"""Test import config flow with all fields."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
2020-01-23 00:55:34 +00:00
|
|
|
context={"source": SOURCE_IMPORT},
|
2020-01-18 08:15:06 +00:00
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(MOCK_IMPORT_VALID_TV_CONFIG),
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
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_ACCESS_TOKEN] == ACCESS_TOKEN
|
|
|
|
assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP
|
|
|
|
|
|
|
|
|
|
|
|
async def test_import_entity_already_configured(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test entity is already configured during import setup."""
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
2020-01-18 08:15:06 +00:00
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(MOCK_SPEAKER_CONFIG),
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
options={CONF_VOLUME_STEP: VOLUME_STEP},
|
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
2020-01-18 08:15:06 +00:00
|
|
|
fail_entry = vol.Schema(VIZIO_SCHEMA)(MOCK_SPEAKER_CONFIG.copy())
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-01-23 00:55:34 +00:00
|
|
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=fail_entry
|
Add Config Flow support, Device Registry support, available property to vizio component (#30653)
* add config flow support, device registry support, available property
* raise PlatformNotReady if HA cant connect to device
* remove test logging statement and fix integration title
* store import and last user input values so user can see errors next to value that caused error
* add PARALLEL_UPDATES
* add missing type hints
* add missing type hints to tests
* fix options config flow title
* changes based on review
* better key name for message when cant connect
* fix missed update to key name
* fix comments
* remove logger from test which was used to debug and update test function names and docstrings to be more accurate
* add __init__.py to vizio tests module
* readded options flow and updated main component to handle options updates, set unique ID to serial, fixes based on review
* pop hass.data in media_player unload instead of in __init__ since it is set in media_player
* update requirements_all and requirements_test_all
* make unique_id key name a constant
* remove additional line breaks after docstrings
* unload entries during test_user_flow and test_import_flow tests to hopefully reduce teardown time
* try to speed up tests
* remove unnecessary code, use event bus to track options updates, move patches to pytest fixtures and fix patch scoping
* fix comment
* remove translations from commit
* suppress API error logging when checking for device availability as it can spam logs
* update requirements_all and requirements_test_all
* dont pass hass to entity since it is passed to entity anyway, remove entity unload from tests, other misc changes from review
* fix clearing listeners
* use config_entry unique ID for unique ID and use config_entry entry ID as update signal
* update config flow based on suggested changes
* update volume step on config import if it doesn't match config_entry volume step
* update config_entry data and options with new volume step value
* copy entry.data and entry.options before updating when updating config_entry
* fix test_import_entity_already_configured
2020-01-15 10:43:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "already_setup"
|
2020-01-20 04:13:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_import_flow_update_options(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_update: pytest.fixture,
|
2020-01-20 04:13:15 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test import config flow with updated options."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_IMPORT},
|
2020-02-24 22:37:54 +00:00
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(MOCK_SPEAKER_CONFIG),
|
2020-01-20 04:13:15 +00:00
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
2020-01-23 00:55:34 +00:00
|
|
|
|
2020-02-24 22:37:54 +00:00
|
|
|
assert result["result"].options == {CONF_VOLUME_STEP: DEFAULT_VOLUME_STEP}
|
2020-01-20 04:13:15 +00:00
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
entry_id = result["result"].entry_id
|
|
|
|
|
2020-02-24 22:37:54 +00:00
|
|
|
updated_config = MOCK_SPEAKER_CONFIG.copy()
|
2020-01-20 04:13:15 +00:00
|
|
|
updated_config[CONF_VOLUME_STEP] = VOLUME_STEP + 1
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_IMPORT},
|
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(updated_config),
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
2020-02-04 19:31:03 +00:00
|
|
|
assert result["reason"] == "updated_entry"
|
2020-03-13 11:16:24 +00:00
|
|
|
config_entry = hass.config_entries.async_get_entry(entry_id)
|
|
|
|
assert config_entry.options[CONF_VOLUME_STEP] == VOLUME_STEP + 1
|
2020-01-22 09:13:35 +00:00
|
|
|
|
|
|
|
|
2020-03-05 21:34:12 +00:00
|
|
|
async def test_import_flow_update_name_and_apps(
|
2020-02-04 19:31:03 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_update: pytest.fixture,
|
|
|
|
) -> None:
|
2020-03-05 21:34:12 +00:00
|
|
|
"""Test import config flow with updated name and apps."""
|
2020-02-04 19:31:03 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_IMPORT},
|
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(MOCK_IMPORT_VALID_TV_CONFIG),
|
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
assert result["result"].data[CONF_NAME] == NAME
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
entry_id = result["result"].entry_id
|
|
|
|
|
|
|
|
updated_config = MOCK_IMPORT_VALID_TV_CONFIG.copy()
|
|
|
|
updated_config[CONF_NAME] = NAME2
|
2020-03-05 21:34:12 +00:00
|
|
|
updated_config[CONF_APPS] = {CONF_INCLUDE: [CURRENT_APP]}
|
2020-02-04 19:31:03 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_IMPORT},
|
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(updated_config),
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "updated_entry"
|
2020-03-13 11:16:24 +00:00
|
|
|
config_entry = hass.config_entries.async_get_entry(entry_id)
|
|
|
|
assert config_entry.data[CONF_NAME] == NAME2
|
|
|
|
assert config_entry.data[CONF_APPS] == {CONF_INCLUDE: [CURRENT_APP]}
|
|
|
|
assert config_entry.options[CONF_APPS] == {CONF_INCLUDE: [CURRENT_APP]}
|
2020-03-05 21:34:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_import_flow_update_remove_apps(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_update: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test import config flow with removed apps."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_IMPORT},
|
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(MOCK_TV_WITH_EXCLUDE_CONFIG),
|
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
assert result["result"].data[CONF_NAME] == NAME
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
2020-03-13 11:16:24 +00:00
|
|
|
config_entry = hass.config_entries.async_get_entry(result["result"].entry_id)
|
|
|
|
assert CONF_APPS in config_entry.data
|
|
|
|
assert CONF_APPS in config_entry.options
|
2020-03-05 21:34:12 +00:00
|
|
|
|
|
|
|
updated_config = MOCK_TV_WITH_EXCLUDE_CONFIG.copy()
|
|
|
|
updated_config.pop(CONF_APPS)
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_IMPORT},
|
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(updated_config),
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "updated_entry"
|
2020-03-13 11:16:24 +00:00
|
|
|
assert CONF_APPS not in config_entry.data
|
|
|
|
assert CONF_APPS not in config_entry.options
|
2020-02-04 19:31:03 +00:00
|
|
|
|
|
|
|
|
2020-02-28 06:04:59 +00:00
|
|
|
async def test_import_needs_pairing(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
vizio_complete_pairing: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test pairing config flow when access token not provided for tv during import."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_TV_CONFIG_NO_TOKEN
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "user"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=MOCK_TV_CONFIG_NO_TOKEN
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "pair_tv"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=MOCK_PIN_CONFIG
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "pairing_complete_import"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2020-03-05 21:34:12 +00:00
|
|
|
async def test_import_with_apps_needs_pairing(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
vizio_complete_pairing: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test pairing config flow when access token not provided for tv but apps are included during import."""
|
|
|
|
import_config = MOCK_TV_CONFIG_NO_TOKEN.copy()
|
|
|
|
import_config[CONF_APPS] = {CONF_INCLUDE: [CURRENT_APP]}
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=import_config
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "user"
|
|
|
|
|
|
|
|
# Mock inputting info without apps to make sure apps get stored
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"],
|
|
|
|
user_input=_get_config_schema(MOCK_TV_CONFIG_NO_TOKEN)(MOCK_TV_CONFIG_NO_TOKEN),
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "pair_tv"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=MOCK_PIN_CONFIG
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "pairing_complete_import"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
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_APPS][CONF_INCLUDE] == [CURRENT_APP]
|
|
|
|
|
|
|
|
|
2020-03-13 11:16:24 +00:00
|
|
|
async def test_import_flow_additional_configs(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_update: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test import config flow with additional configs defined in CONF_APPS."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_IMPORT},
|
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(MOCK_TV_WITH_ADDITIONAL_APPS_CONFIG),
|
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
assert result["result"].data[CONF_NAME] == NAME
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
config_entry = hass.config_entries.async_get_entry(result["result"].entry_id)
|
|
|
|
assert CONF_APPS in config_entry.data
|
|
|
|
assert CONF_APPS not in config_entry.options
|
|
|
|
|
|
|
|
|
2020-02-28 06:04:59 +00:00
|
|
|
async def test_import_error(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
caplog: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test that error is logged when import config has an error."""
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(MOCK_SPEAKER_CONFIG),
|
|
|
|
options={CONF_VOLUME_STEP: VOLUME_STEP},
|
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
fail_entry = MOCK_SPEAKER_CONFIG.copy()
|
|
|
|
fail_entry[CONF_HOST] = "0.0.0.0"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_IMPORT},
|
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(fail_entry),
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
|
|
|
|
# Ensure error gets logged
|
|
|
|
vizio_log_list = [
|
|
|
|
log
|
|
|
|
for log in caplog.records
|
|
|
|
if log.name == "homeassistant.components.vizio.config_flow"
|
|
|
|
]
|
|
|
|
assert len(vizio_log_list) == 1
|
|
|
|
|
|
|
|
|
2020-04-16 21:53:34 +00:00
|
|
|
async def test_import_ignore(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test import config flow doesn't throw an error when there's an existing ignored source."""
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
|
|
|
data=MOCK_SPEAKER_CONFIG,
|
|
|
|
options={CONF_VOLUME_STEP: VOLUME_STEP},
|
|
|
|
source=SOURCE_IGNORE,
|
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_IMPORT},
|
|
|
|
data=vol.Schema(VIZIO_SCHEMA)(MOCK_SPEAKER_CONFIG),
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
|
|
|
|
|
2020-01-22 09:13:35 +00:00
|
|
|
async def test_zeroconf_flow(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
vizio_guess_device_type: pytest.fixture,
|
2020-01-22 09:13:35 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test zeroconf config flow."""
|
2020-01-30 21:13:45 +00:00
|
|
|
discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy()
|
2020-01-22 09:13:35 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
|
|
|
)
|
|
|
|
|
|
|
|
# Form should always show even if all required properties are discovered
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "user"
|
|
|
|
|
2020-01-31 16:33:00 +00:00
|
|
|
# Apply discovery updates to entry to mimic when user hits submit without changing
|
2020-01-22 09:13:35 +00:00
|
|
|
# defaults which were set from discovery parameters
|
|
|
|
user_input = result["data_schema"](discovery_info)
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=user_input
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_flow_already_configured(
|
2020-01-23 00:55:34 +00:00
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
2020-01-22 09:13:35 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test entity is already configured during zeroconf setup."""
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN, data=MOCK_SPEAKER_CONFIG, options={CONF_VOLUME_STEP: VOLUME_STEP}
|
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
# Try rediscovering same device
|
2020-01-30 21:13:45 +00:00
|
|
|
discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy()
|
2020-01-22 09:13:35 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
|
|
|
)
|
|
|
|
|
|
|
|
# Flow should abort because device is already setup
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "already_setup"
|
2020-02-10 22:54:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_dupe_fail(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
vizio_guess_device_type: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test zeroconf config flow when device gets discovered multiple times."""
|
|
|
|
discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy()
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
|
|
|
)
|
|
|
|
|
|
|
|
# Form should always show even if all required properties are discovered
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "user"
|
|
|
|
|
|
|
|
discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy()
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
|
|
|
)
|
|
|
|
|
|
|
|
# Flow should abort because device is already setup
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "already_in_progress"
|
2020-04-16 21:53:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_ignore(
|
|
|
|
hass: HomeAssistantType,
|
|
|
|
vizio_connect: pytest.fixture,
|
|
|
|
vizio_bypass_setup: pytest.fixture,
|
|
|
|
vizio_guess_device_type: pytest.fixture,
|
|
|
|
) -> None:
|
|
|
|
"""Test zeroconf discovery doesn't throw an error when there's an existing ignored source."""
|
|
|
|
entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
|
|
|
data=MOCK_SPEAKER_CONFIG,
|
|
|
|
options={CONF_VOLUME_STEP: VOLUME_STEP},
|
|
|
|
source=SOURCE_IGNORE,
|
|
|
|
)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy()
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|