Filter out duplicate app names from vizio's source list (#33051)

* filter out additional app config names from pyvizios app list

* add test

* change where filtering app list occurs

* fix test

* fix mistake in change

* hopefully final test fix

* fix test scenario that unknowingly broke with test change
This commit is contained in:
Raman Gupta 2020-03-22 12:34:00 -04:00 committed by GitHub
parent 912cda4e6f
commit ca3a22b5a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View file

@ -335,7 +335,11 @@ class VizioDevice(MediaPlayerDevice):
if _input not in INPUT_APPS
],
*self._available_apps,
*self._get_additional_app_names(),
*[
app
for app in self._get_additional_app_names()
if app not in self._available_apps
],
]
return self._available_inputs

View file

@ -70,10 +70,9 @@ INPUT_LIST = ["HDMI", "USB", "Bluetooth", "AUX"]
CURRENT_APP = "Hulu"
APP_LIST = ["Hulu", "Netflix"]
INPUT_LIST_WITH_APPS = INPUT_LIST + ["CAST"]
CUSTOM_APP_NAME = "APP3"
CUSTOM_CONFIG = {CONF_APP_ID: "test", CONF_MESSAGE: None, CONF_NAME_SPACE: 10}
ADDITIONAL_APP_CONFIG = {
"name": CUSTOM_APP_NAME,
"name": CURRENT_APP,
CONF_CONFIG: CUSTOM_CONFIG,
}

View file

@ -58,7 +58,6 @@ from .const import (
APP_LIST,
CURRENT_APP,
CURRENT_INPUT,
CUSTOM_APP_NAME,
CUSTOM_CONFIG,
ENTITY_ID,
INPUT_LIST,
@ -180,11 +179,15 @@ async def _test_setup_with_apps(
+ [
app["name"]
for app in device_config[CONF_APPS][CONF_ADDITIONAL_CONFIGS]
if app["name"] not in APP_LIST
]
)
else:
list_to_test = list(INPUT_LIST_WITH_APPS + APP_LIST)
if CONF_ADDITIONAL_CONFIGS in device_config.get(CONF_APPS, {}):
assert attr["source_list"].count(CURRENT_APP) == 1
for app_to_remove in INPUT_APPS:
if app_to_remove in list_to_test:
list_to_test.remove(app_to_remove)
@ -471,14 +474,14 @@ async def test_setup_with_apps_additional_apps_config(
hass,
"launch_app",
SERVICE_SELECT_SOURCE,
{ATTR_INPUT_SOURCE: CURRENT_APP},
CURRENT_APP,
{ATTR_INPUT_SOURCE: "Netflix"},
"Netflix",
)
await _test_service(
hass,
"launch_app_config",
SERVICE_SELECT_SOURCE,
{ATTR_INPUT_SOURCE: CUSTOM_APP_NAME},
{ATTR_INPUT_SOURCE: CURRENT_APP},
**CUSTOM_CONFIG,
)