From 0ae5c325fe6394711bb000bfb7daf4044ba45b6f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 20 Mar 2020 13:34:56 -0700 Subject: [PATCH 1/5] Add negative tests for identify schema for packages (#33050) --- homeassistant/config.py | 19 +++++++++---------- tests/test_config.py | 11 +++++++---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/homeassistant/config.py b/homeassistant/config.py index b1cd49b0852..bd956846886 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -562,12 +562,12 @@ def _log_pkg_error(package: str, component: str, config: Dict, message: str) -> _LOGGER.error(message) -def _identify_config_schema(module: ModuleType) -> Tuple[Optional[str], Optional[Dict]]: +def _identify_config_schema(module: ModuleType) -> Optional[str]: """Extract the schema and identify list or dict based.""" try: key = next(k for k in module.CONFIG_SCHEMA.schema if k == module.DOMAIN) # type: ignore except (AttributeError, StopIteration): - return None, None + return None schema = module.CONFIG_SCHEMA.schema[key] # type: ignore @@ -577,19 +577,19 @@ def _identify_config_schema(module: ModuleType) -> Tuple[Optional[str], Optional default_value = schema(key.default()) if isinstance(default_value, dict): - return "dict", schema + return "dict" if isinstance(default_value, list): - return "list", schema + return "list" - return None, None + return None t_schema = str(schema) if t_schema.startswith("{") or "schema_with_slug_keys" in t_schema: - return ("dict", schema) + return "dict" if t_schema.startswith(("[", "All( Union[bool, str]: @@ -642,8 +642,7 @@ async def merge_packages_config( merge_list = hasattr(component, "PLATFORM_SCHEMA") if not merge_list and hasattr(component, "CONFIG_SCHEMA"): - merge_type, _ = _identify_config_schema(component) - merge_list = merge_type == "list" + merge_list = _identify_config_schema(component) == "list" if merge_list: config[comp_name] = cv.remove_falsy( diff --git a/tests/test_config.py b/tests/test_config.py index 43f1263e581..ba0153e7a7d 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -722,7 +722,7 @@ async def test_merge_id_schema(hass): for domain, expected_type in types.items(): integration = await async_get_integration(hass, domain) module = integration.get_component() - typ, _ = config_util._identify_config_schema(module) + typ = config_util._identify_config_schema(module) assert typ == expected_type, f"{domain} expected {expected_type}, got {typ}" @@ -997,13 +997,16 @@ async def test_component_config_exceptions(hass, caplog): [ ("zone", vol.Schema({vol.Optional("zone", default=[]): list}), "list"), ("zone", vol.Schema({vol.Optional("zone", default=dict): dict}), "dict"), + ("zone", vol.Schema({vol.Optional("zone"): int}), None), + ("zone", vol.Schema({"zone": int}), None), + ("not_existing", vol.Schema({vol.Optional("zone", default=dict): dict}), None,), + ("non_existing", vol.Schema({"zone": int}), None), + ("zone", vol.Schema({}), None), ], ) def test_identify_config_schema(domain, schema, expected): """Test identify config schema.""" assert ( - config_util._identify_config_schema(Mock(DOMAIN=domain, CONFIG_SCHEMA=schema))[ - 0 - ] + config_util._identify_config_schema(Mock(DOMAIN=domain, CONFIG_SCHEMA=schema)) == expected ) From 312903025d3be3c180745c8271b8ff7e0ebfc9d1 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Fri, 20 Mar 2020 14:59:01 -0600 Subject: [PATCH 2/5] Bump simplisafe-python to 9.0.4 (#33059) --- homeassistant/components/simplisafe/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/simplisafe/manifest.json b/homeassistant/components/simplisafe/manifest.json index 0fdcdcfcf5e..1d010c67692 100644 --- a/homeassistant/components/simplisafe/manifest.json +++ b/homeassistant/components/simplisafe/manifest.json @@ -3,7 +3,7 @@ "name": "SimpliSafe", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/simplisafe", - "requirements": ["simplisafe-python==9.0.3"], + "requirements": ["simplisafe-python==9.0.4"], "dependencies": [], "codeowners": ["@bachya"] } diff --git a/requirements_all.txt b/requirements_all.txt index 11d241bbc9f..36ca24a0792 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1856,7 +1856,7 @@ simplehound==0.3 simplepush==1.1.4 # homeassistant.components.simplisafe -simplisafe-python==9.0.3 +simplisafe-python==9.0.4 # homeassistant.components.sisyphus sisyphus-control==2.2.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index f21ef66187e..5252667985a 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -649,7 +649,7 @@ sentry-sdk==0.13.5 simplehound==0.3 # homeassistant.components.simplisafe -simplisafe-python==9.0.3 +simplisafe-python==9.0.4 # homeassistant.components.sleepiq sleepyq==0.7 From edbb995fff913b67440ebc1033cf5b514fc52591 Mon Sep 17 00:00:00 2001 From: Knapoc Date: Fri, 20 Mar 2020 21:34:17 +0100 Subject: [PATCH 3/5] Bump aioasuswrt to 1.2.3 and fix asuswrt sensor (#33064) * Bump aioasuswrt to 1.2.3 * Fix asuswrt connection setup parameters * fix typo --- homeassistant/components/asuswrt/__init__.py | 4 ++-- homeassistant/components/asuswrt/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/asuswrt/__init__.py b/homeassistant/components/asuswrt/__init__.py index f2d7a72e54d..a0afbed69f1 100644 --- a/homeassistant/components/asuswrt/__init__.py +++ b/homeassistant/components/asuswrt/__init__.py @@ -73,8 +73,8 @@ async def async_setup(hass, config): conf.get("ssh_key", conf.get("pub_key", "")), conf[CONF_MODE], conf[CONF_REQUIRE_IP], - conf[CONF_INTERFACE], - conf[CONF_DNSMASQ], + interface=conf[CONF_INTERFACE], + dnsmasq=conf[CONF_DNSMASQ], ) await api.connection.async_connect() diff --git a/homeassistant/components/asuswrt/manifest.json b/homeassistant/components/asuswrt/manifest.json index c161dc4f536..2e032dedfe7 100644 --- a/homeassistant/components/asuswrt/manifest.json +++ b/homeassistant/components/asuswrt/manifest.json @@ -2,7 +2,7 @@ "domain": "asuswrt", "name": "ASUSWRT", "documentation": "https://www.home-assistant.io/integrations/asuswrt", - "requirements": ["aioasuswrt==1.2.2"], + "requirements": ["aioasuswrt==1.2.3"], "dependencies": [], "codeowners": ["@kennedyshead"] } diff --git a/requirements_all.txt b/requirements_all.txt index 36ca24a0792..27f7277b373 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -139,7 +139,7 @@ aio_georss_gdacs==0.3 aioambient==1.0.4 # homeassistant.components.asuswrt -aioasuswrt==1.2.2 +aioasuswrt==1.2.3 # homeassistant.components.automatic aioautomatic==0.6.5 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 5252667985a..8d22e748a16 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -50,7 +50,7 @@ aio_georss_gdacs==0.3 aioambient==1.0.4 # homeassistant.components.asuswrt -aioasuswrt==1.2.2 +aioasuswrt==1.2.3 # homeassistant.components.automatic aioautomatic==0.6.5 From 57998f6f0f6317338fb65b10d3f524c4ce509207 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 20 Mar 2020 20:27:37 -0700 Subject: [PATCH 4/5] Fix package default extraction (#33071) --- homeassistant/config.py | 4 +++- tests/test_config.py | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/homeassistant/config.py b/homeassistant/config.py index bd956846886..b63acf4ab4c 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -574,7 +574,9 @@ def _identify_config_schema(module: ModuleType) -> Optional[str]: if hasattr(key, "default") and not isinstance( key.default, vol.schema_builder.Undefined ): - default_value = schema(key.default()) + default_value = module.CONFIG_SCHEMA({module.DOMAIN: key.default()})[ # type: ignore + module.DOMAIN # type: ignore + ] if isinstance(default_value, dict): return "dict" diff --git a/tests/test_config.py b/tests/test_config.py index ba0153e7a7d..f226c72f7ad 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -995,8 +995,20 @@ async def test_component_config_exceptions(hass, caplog): @pytest.mark.parametrize( "domain, schema, expected", [ - ("zone", vol.Schema({vol.Optional("zone", default=[]): list}), "list"), - ("zone", vol.Schema({vol.Optional("zone", default=dict): dict}), "dict"), + ("zone", vol.Schema({vol.Optional("zone", default=list): [int]}), "list"), + ("zone", vol.Schema({vol.Optional("zone", default=[]): [int]}), "list"), + ( + "zone", + vol.Schema({vol.Optional("zone", default={}): {vol.Optional("hello"): 1}}), + "dict", + ), + ( + "zone", + vol.Schema( + {vol.Optional("zone", default=dict): {vol.Optional("hello"): 1}} + ), + "dict", + ), ("zone", vol.Schema({vol.Optional("zone"): int}), None), ("zone", vol.Schema({"zone": int}), None), ("not_existing", vol.Schema({vol.Optional("zone", default=dict): dict}), None,), From 663db747e9acd0aea65e1275cbbc4d69af291656 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 20 Mar 2020 23:02:50 -0700 Subject: [PATCH 5/5] Bumped version to 0.107.4 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 86ef567be6d..3b88f9710bd 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 107 -PATCH_VERSION = "3" +PATCH_VERSION = "4" __short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__ = f"{__short_version__}.{PATCH_VERSION}" REQUIRED_PYTHON_VER = (3, 7, 0)