Add tests for component configuration with multiple errors (#103964)
* Add tests for component configuration with multiple errors * Add new configuration file * Fix typo --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
2d39eaf0a2
commit
381ebf3e53
12 changed files with 111 additions and 10 deletions
tests
fixtures/core/config/component_validation
basic
basic_include
include_dir_list/iot_domain
include_dir_merge_list/iot_domain
packages
packages_include_dir_named/integrations
snapshots
test_config.py
|
@ -10,6 +10,14 @@ iot_domain:
|
|||
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||
- platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option1: abc
|
||||
# This violates the non_adr_0007.iot_domain platform schema:
|
||||
# - no_such_option does not exist
|
||||
# - option1 is missing
|
||||
# - option2 is wrong type
|
||||
- platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option2: 123
|
||||
|
||||
# This is correct and should not generate errors
|
||||
adr_0007_1:
|
||||
|
@ -27,3 +35,11 @@ adr_0007_3:
|
|||
adr_0007_4:
|
||||
host: blah.com
|
||||
no_such_option: foo
|
||||
|
||||
# Multiple errors:
|
||||
# - host is missing
|
||||
# - no_such_option does not exist
|
||||
# - port is wrong type
|
||||
adr_0007_5:
|
||||
no_such_option: foo
|
||||
port: foo
|
||||
|
|
|
@ -2,3 +2,5 @@ iot_domain: !include integrations/iot_domain.yaml
|
|||
adr_0007_1: !include integrations/adr_0007_1.yaml
|
||||
adr_0007_2: !include integrations/adr_0007_2.yaml
|
||||
adr_0007_3: !include integrations/adr_0007_3.yaml
|
||||
adr_0007_4: !include integrations/adr_0007_4.yaml
|
||||
adr_0007_5: !include integrations/adr_0007_5.yaml
|
||||
|
|
6
tests/fixtures/core/config/component_validation/basic_include/integrations/adr_0007_5.yaml
vendored
Normal file
6
tests/fixtures/core/config/component_validation/basic_include/integrations/adr_0007_5.yaml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Multiple errors:
|
||||
# - host is missing
|
||||
# - no_such_option does not exist
|
||||
# - port is wrong type
|
||||
no_such_option: foo
|
||||
port: foo
|
|
@ -9,3 +9,11 @@
|
|||
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||
- platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option1: abc
|
||||
# This violates the non_adr_0007.iot_domain platform schema:
|
||||
# - no_such_option does not exist
|
||||
# - option1 is missing
|
||||
# - option2 is wrong type
|
||||
- platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option2: 123
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||
platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option1: abc
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# This violates the non_adr_0007.iot_domain platform schema:
|
||||
# - no_such_option does not exist
|
||||
# - option1 is missing
|
||||
# - option2 is wrong type
|
||||
platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option2: 123
|
|
@ -4,3 +4,11 @@
|
|||
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||
- platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option1: abc
|
||||
# This violates the non_adr_0007.iot_domain platform schema:
|
||||
# - no_such_option does not exist
|
||||
# - option1 is missing
|
||||
# - option2 is wrong type
|
||||
- platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option2: 123
|
||||
|
|
|
@ -19,6 +19,16 @@ homeassistant:
|
|||
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||
- platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option1: abc
|
||||
pack_iot_domain_5:
|
||||
iot_domain:
|
||||
# This violates the non_adr_0007.iot_domain platform schema:
|
||||
# - no_such_option does not exist
|
||||
# - option1 is missing
|
||||
# - option2 is wrong type
|
||||
- platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option2: 123
|
||||
pack_adr_0007_1:
|
||||
# This is correct and should not generate errors
|
||||
adr_0007_1:
|
||||
|
@ -36,3 +46,11 @@ homeassistant:
|
|||
adr_0007_4:
|
||||
host: blah.com
|
||||
no_such_option: foo
|
||||
pack_adr_0007_5:
|
||||
# Multiple errors:
|
||||
# - host is missing
|
||||
# - no_such_option does not exist
|
||||
# - port is wrong type
|
||||
adr_0007_5:
|
||||
no_such_option: foo
|
||||
port: foo
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# Multiple errors:
|
||||
# - host is missing
|
||||
# - no_such_option does not exist
|
||||
# - port is wrong type
|
||||
adr_0007_5:
|
||||
no_such_option: foo
|
||||
port: foo
|
|
@ -9,4 +9,12 @@ iot_domain:
|
|||
option1: 123
|
||||
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||
- platform: non_adr_0007
|
||||
- no_such_option: abc
|
||||
no_such_option: abc
|
||||
option1: abc
|
||||
# This violates the non_adr_0007.iot_domain platform schema:
|
||||
# - no_such_option does not exist
|
||||
# - option1 is missing
|
||||
# - option2 is wrong type
|
||||
- platform: non_adr_0007
|
||||
no_such_option: abc
|
||||
option2: 123
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 6: required key not provided 'platform', got None.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 9: expected str for dictionary value 'option1', got 123.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 12: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 19: required key not provided 'adr_0007_2->host', got None.",
|
||||
"Invalid config for [adr_0007_3] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 24: expected int for dictionary value 'adr_0007_3->port', got 'foo'.",
|
||||
"Invalid config for [adr_0007_4] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 29: 'no_such_option' is an invalid option for [adr_0007_4], check: adr_0007_4->no_such_option",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 19: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 27: required key not provided 'adr_0007_2->host', got None.",
|
||||
"Invalid config for [adr_0007_3] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 32: expected int for dictionary value 'adr_0007_3->port', got 'foo'.",
|
||||
"Invalid config for [adr_0007_4] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 37: 'no_such_option' is an invalid option for [adr_0007_4], check: adr_0007_4->no_such_option",
|
||||
"Invalid config for [adr_0007_5] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 44: 'no_such_option' is an invalid option for [adr_0007_5], check: adr_0007_5->no_such_option",
|
||||
])
|
||||
# ---
|
||||
# name: test_component_config_validation_error[basic_include]
|
||||
|
@ -14,8 +16,11 @@
|
|||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/integrations/iot_domain.yaml, line 5: required key not provided 'platform', got None.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/integrations/iot_domain.yaml, line 8: expected str for dictionary value 'option1', got 123.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/integrations/iot_domain.yaml, line 11: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/integrations/iot_domain.yaml, line 18: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/configuration.yaml, line 3: required key not provided 'adr_0007_2->host', got None.",
|
||||
"Invalid config for [adr_0007_3] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/integrations/adr_0007_3.yaml, line 3: expected int for dictionary value 'adr_0007_3->port', got 'foo'.",
|
||||
"Invalid config for [adr_0007_4] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/integrations/adr_0007_4.yaml, line 3: 'no_such_option' is an invalid option for [adr_0007_4], check: adr_0007_4->no_such_option",
|
||||
"Invalid config for [adr_0007_5] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/integrations/adr_0007_5.yaml, line 5: 'no_such_option' is an invalid option for [adr_0007_5], check: adr_0007_5->no_such_option",
|
||||
])
|
||||
# ---
|
||||
# name: test_component_config_validation_error[include_dir_list]
|
||||
|
@ -23,6 +28,7 @@
|
|||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_list/iot_domain/iot_domain_2.yaml, line 2: required key not provided 'platform', got None.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_list/iot_domain/iot_domain_3.yaml, line 3: expected str for dictionary value 'option1', got 123.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_list/iot_domain/iot_domain_4.yaml, line 3: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_list/iot_domain/iot_domain_5.yaml, line 6: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
])
|
||||
# ---
|
||||
# name: test_component_config_validation_error[include_dir_merge_list]
|
||||
|
@ -30,6 +36,7 @@
|
|||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_merge_list/iot_domain/iot_domain_1.yaml, line 5: required key not provided 'platform', got None.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_merge_list/iot_domain/iot_domain_2.yaml, line 3: expected str for dictionary value 'option1', got 123.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_merge_list/iot_domain/iot_domain_2.yaml, line 6: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_merge_list/iot_domain/iot_domain_2.yaml, line 13: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
])
|
||||
# ---
|
||||
# name: test_component_config_validation_error[packages]
|
||||
|
@ -37,19 +44,23 @@
|
|||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 11: required key not provided 'platform', got None.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 16: expected str for dictionary value 'option1', got 123.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 21: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 28: required key not provided 'adr_0007_2->host', got None.",
|
||||
"Invalid config for [adr_0007_3] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 33: expected int for dictionary value 'adr_0007_3->port', got 'foo'.",
|
||||
"Invalid config for [adr_0007_4] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 38: 'no_such_option' is an invalid option for [adr_0007_4], check: adr_0007_4->no_such_option",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 30: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 38: required key not provided 'adr_0007_2->host', got None.",
|
||||
"Invalid config for [adr_0007_3] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 43: expected int for dictionary value 'adr_0007_3->port', got 'foo'.",
|
||||
"Invalid config for [adr_0007_4] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 48: 'no_such_option' is an invalid option for [adr_0007_4], check: adr_0007_4->no_such_option",
|
||||
"Invalid config for [adr_0007_5] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 55: 'no_such_option' is an invalid option for [adr_0007_5], check: adr_0007_5->no_such_option",
|
||||
])
|
||||
# ---
|
||||
# name: test_component_config_validation_error[packages_include_dir_named]
|
||||
list([
|
||||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/iot_domain.yaml, line 6: required key not provided 'platform', got None.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/iot_domain.yaml, line 9: expected str for dictionary value 'option1', got 123.",
|
||||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/iot_domain.yaml, line 12: required key not provided 'platform', got None.",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/iot_domain.yaml, line 12: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/iot_domain.yaml, line 19: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/adr_0007_2.yaml, line 2: required key not provided 'adr_0007_2->host', got None.",
|
||||
"Invalid config for [adr_0007_3] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/adr_0007_3.yaml, line 4: expected int for dictionary value 'adr_0007_3->port', got 'foo'.",
|
||||
"Invalid config for [adr_0007_4] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/adr_0007_4.yaml, line 4: 'no_such_option' is an invalid option for [adr_0007_4], check: adr_0007_4->no_such_option",
|
||||
"Invalid config for [adr_0007_5] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/adr_0007_5.yaml, line 6: 'no_such_option' is an invalid option for [adr_0007_5], check: adr_0007_5->no_such_option",
|
||||
])
|
||||
# ---
|
||||
# name: test_package_merge_error[packages]
|
||||
|
|
|
@ -121,7 +121,9 @@ async def mock_non_adr_0007_integration(hass) -> None:
|
|||
configuration key
|
||||
"""
|
||||
|
||||
test_platform_schema = IOT_DOMAIN_PLATFORM_SCHEMA.extend({"option1": str})
|
||||
test_platform_schema = IOT_DOMAIN_PLATFORM_SCHEMA.extend(
|
||||
{vol.Required("option1"): str, vol.Optional("option2"): str}
|
||||
)
|
||||
mock_platform(
|
||||
hass,
|
||||
"non_adr_0007.iot_domain",
|
||||
|
@ -133,7 +135,13 @@ async def mock_non_adr_0007_integration(hass) -> None:
|
|||
async def mock_adr_0007_integrations(hass) -> list[Integration]:
|
||||
"""Mock ADR-0007 compliant integrations."""
|
||||
integrations = []
|
||||
for domain in ["adr_0007_1", "adr_0007_2", "adr_0007_3", "adr_0007_4"]:
|
||||
for domain in [
|
||||
"adr_0007_1",
|
||||
"adr_0007_2",
|
||||
"adr_0007_3",
|
||||
"adr_0007_4",
|
||||
"adr_0007_5",
|
||||
]:
|
||||
adr_0007_config_schema = vol.Schema(
|
||||
{
|
||||
domain: vol.Schema(
|
||||
|
@ -1504,6 +1512,7 @@ async def test_component_config_validation_error(
|
|||
"adr_0007_2",
|
||||
"adr_0007_3",
|
||||
"adr_0007_4",
|
||||
"adr_0007_5",
|
||||
]:
|
||||
integration = await async_get_integration(hass, domain)
|
||||
await config_util.async_process_component_config(
|
||||
|
|
Loading…
Add table
Reference in a new issue