mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add tests for component configuration with extra keys (#103959)
This commit is contained in:
parent
fe15ed4a28
commit
44c1cef42e
@ -2,11 +2,14 @@ iot_domain:
|
|||||||
# This is correct and should not generate errors
|
# This is correct and should not generate errors
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: abc
|
option1: abc
|
||||||
# This violates the non_adr_0007.iot_domain platform schema
|
# This violates the iot_domain platform schema (platform missing)
|
||||||
|
- paltfrom: non_adr_0007
|
||||||
|
# This violates the non_adr_0007.iot_domain platform schema (option1 wrong type)
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: 123
|
option1: 123
|
||||||
# This violates the iot_domain platform schema
|
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||||
- paltfrom: non_adr_0007
|
- platform: non_adr_0007
|
||||||
|
no_such_option: abc
|
||||||
|
|
||||||
# This is correct and should not generate errors
|
# This is correct and should not generate errors
|
||||||
adr_0007_1:
|
adr_0007_1:
|
||||||
@ -19,3 +22,8 @@ adr_0007_2:
|
|||||||
adr_0007_3:
|
adr_0007_3:
|
||||||
host: blah.com
|
host: blah.com
|
||||||
port: foo
|
port: foo
|
||||||
|
|
||||||
|
# no_such_option does not exist
|
||||||
|
adr_0007_4:
|
||||||
|
host: blah.com
|
||||||
|
no_such_option: foo
|
||||||
|
3
tests/fixtures/core/config/component_validation/basic_include/integrations/adr_0007_4.yaml
vendored
Normal file
3
tests/fixtures/core/config/component_validation/basic_include/integrations/adr_0007_4.yaml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# no_such_option does not exist
|
||||||
|
host: blah.com
|
||||||
|
no_such_option: foo
|
@ -1,8 +1,11 @@
|
|||||||
# This is correct and should not generate errors
|
# This is correct and should not generate errors
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: abc
|
option1: abc
|
||||||
# This violates the non_adr_0007.iot_domain platform schema
|
# This violates the iot_domain platform schema (platform missing)
|
||||||
|
- paltfrom: non_adr_0007
|
||||||
|
# This violates the non_adr_0007.iot_domain platform schema (option1 wrong type)
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: 123
|
option1: 123
|
||||||
# This violates the iot_domain platform schema
|
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||||
- paltfrom: non_adr_0007
|
- platform: non_adr_0007
|
||||||
|
no_such_option: abc
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
# This violates the non_adr_0007.iot_domain platform schema
|
# This violates the iot_domain platform schema (platform missing)
|
||||||
platform: non_adr_0007
|
paltfrom: non_adr_0007
|
||||||
option1: 123
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
# This violates the iot_domain platform schema
|
# This violates the non_adr_0007.iot_domain platform schema (option1 wrong type)
|
||||||
paltfrom: non_adr_0007
|
platform: non_adr_0007
|
||||||
|
option1: 123
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||||
|
platform: non_adr_0007
|
||||||
|
no_such_option: abc
|
@ -1,3 +1,5 @@
|
|||||||
# This is correct and should not generate errors
|
# This is correct and should not generate errors
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: abc
|
option1: abc
|
||||||
|
# This violates the iot_domain platform schema (platform missing)
|
||||||
|
- paltfrom: non_adr_0007
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# This violates the non_adr_0007.iot_domain platform schema
|
# This violates the non_adr_0007.iot_domain platform schema (option1 wrong type)
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: 123
|
option1: 123
|
||||||
# This violates the iot_domain platform schema
|
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||||
- paltfrom: non_adr_0007
|
- platform: non_adr_0007
|
||||||
|
no_such_option: abc
|
||||||
|
@ -1,28 +1,38 @@
|
|||||||
homeassistant:
|
homeassistant:
|
||||||
packages:
|
packages:
|
||||||
pack_1:
|
pack_iot_domain_1:
|
||||||
iot_domain:
|
iot_domain:
|
||||||
# This is correct and should not generate errors
|
# This is correct and should not generate errors
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: abc
|
option1: abc
|
||||||
pack_2:
|
pack_iot_domain_2:
|
||||||
iot_domain:
|
iot_domain:
|
||||||
# This violates the non_adr_0007.iot_domain platform schema
|
# This violates the iot_domain platform schema (platform missing)
|
||||||
|
- paltfrom: non_adr_0007
|
||||||
|
pack_iot_domain_3:
|
||||||
|
iot_domain:
|
||||||
|
# This violates the non_adr_0007.iot_domain platform schema (option1 wrong type)
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: 123
|
option1: 123
|
||||||
pack_3:
|
pack_iot_domain_4:
|
||||||
iot_domain:
|
iot_domain:
|
||||||
# This violates the iot_domain platform schema
|
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||||
- paltfrom: non_adr_0007
|
- platform: non_adr_0007
|
||||||
pack_4:
|
no_such_option: abc
|
||||||
|
pack_adr_0007_1:
|
||||||
# This is correct and should not generate errors
|
# This is correct and should not generate errors
|
||||||
adr_0007_1:
|
adr_0007_1:
|
||||||
host: blah.com
|
host: blah.com
|
||||||
pack_5:
|
pack_adr_0007_2:
|
||||||
# Host is missing
|
# Host is missing
|
||||||
adr_0007_2:
|
adr_0007_2:
|
||||||
pack_6:
|
pack_adr_0007_3:
|
||||||
# Port is wrong type
|
# Port is wrong type
|
||||||
adr_0007_3:
|
adr_0007_3:
|
||||||
host: blah.com
|
host: blah.com
|
||||||
port: foo
|
port: foo
|
||||||
|
pack_adr_0007_4:
|
||||||
|
# no_such_option does not exist
|
||||||
|
adr_0007_4:
|
||||||
|
host: blah.com
|
||||||
|
no_such_option: foo
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
# no_such_option does not exist
|
||||||
|
adr_0007_4:
|
||||||
|
host: blah.com
|
||||||
|
no_such_option: foo
|
@ -2,8 +2,11 @@ iot_domain:
|
|||||||
# This is correct and should not generate errors
|
# This is correct and should not generate errors
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: abc
|
option1: abc
|
||||||
# This violates the non_adr_0007.iot_domain platform schema
|
# This violates the iot_domain platform schema (platform missing)
|
||||||
|
- paltfrom: non_adr_0007
|
||||||
|
# This violates the non_adr_0007.iot_domain platform schema (option1 wrong type)
|
||||||
- platform: non_adr_0007
|
- platform: non_adr_0007
|
||||||
option1: 123
|
option1: 123
|
||||||
# This violates the iot_domain platform schema
|
# This violates the non_adr_0007.iot_domain platform schema (no_such_option does not exist)
|
||||||
- paltfrom: non_adr_0007
|
- platform: non_adr_0007
|
||||||
|
- no_such_option: abc
|
||||||
|
@ -1,46 +1,55 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
# name: test_component_config_validation_error[basic]
|
# name: test_component_config_validation_error[basic]
|
||||||
list([
|
list([
|
||||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 7: expected str for dictionary value @ data['option1']. Got 123.",
|
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 6: required key not provided @ data['platform']. Got None.",
|
||||||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 9: required key not provided @ data['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 @ data['option1']. Got 123.",
|
||||||
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 16: required key not provided @ data['adr_0007_2']['host']. Got None.",
|
"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_3] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 21: expected int for dictionary value @ data['adr_0007_3']['port']. Got 'foo'.",
|
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/basic/configuration.yaml, line 19: required key not provided @ data['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 @ data['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",
|
||||||
])
|
])
|
||||||
# ---
|
# ---
|
||||||
# name: test_component_config_validation_error[basic_include]
|
# name: test_component_config_validation_error[basic_include]
|
||||||
list([
|
list([
|
||||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/integrations/iot_domain.yaml, line 6: expected str for dictionary value @ data['option1']. Got 123.",
|
"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 @ data['platform']. Got None.",
|
||||||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/integrations/iot_domain.yaml, line 8: required key not provided @ data['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 @ data['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 [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/configuration.yaml, line 3: required key not provided @ data['adr_0007_2']['host']. Got None.",
|
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/basic_include/configuration.yaml, line 3: required key not provided @ data['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 @ data['adr_0007_3']['port']. Got 'foo'.",
|
"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 @ data['adr_0007_3']['port']. Got 'foo'.",
|
||||||
])
|
])
|
||||||
# ---
|
# ---
|
||||||
# name: test_component_config_validation_error[include_dir_list]
|
# name: test_component_config_validation_error[include_dir_list]
|
||||||
list([
|
list([
|
||||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_list/iot_domain/iot_domain_2.yaml, line 3: expected str for dictionary value @ data['option1']. Got 123.",
|
"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 @ data['platform']. Got None.",
|
||||||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_list/iot_domain/iot_domain_3.yaml, line 2: required key not provided @ data['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 @ data['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",
|
||||||
])
|
])
|
||||||
# ---
|
# ---
|
||||||
# name: test_component_config_validation_error[include_dir_merge_list]
|
# name: test_component_config_validation_error[include_dir_merge_list]
|
||||||
list([
|
list([
|
||||||
|
"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 @ data['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 @ data['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 3: expected str for dictionary value @ data['option1']. Got 123.",
|
||||||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/include_dir_merge_list/iot_domain/iot_domain_2.yaml, line 5: required key not provided @ data['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 6: 'no_such_option' is an invalid option for [iot_domain.non_adr_0007], check: no_such_option",
|
||||||
])
|
])
|
||||||
# ---
|
# ---
|
||||||
# name: test_component_config_validation_error[packages]
|
# name: test_component_config_validation_error[packages]
|
||||||
list([
|
list([
|
||||||
"Invalid config for [iot_domain.non_adr_0007] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 12: expected str for dictionary value @ data['option1']. Got 123.",
|
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 11: required key not provided @ data['platform']. Got None.",
|
||||||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 16: required key not provided @ data['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 @ data['option1']. Got 123.",
|
||||||
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 23: required key not provided @ data['adr_0007_2']['host']. Got None.",
|
"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_3] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 28: expected int for dictionary value @ data['adr_0007_3']['port']. Got 'foo'.",
|
"Invalid config for [adr_0007_2] at <BASE_PATH>/fixtures/core/config/component_validation/packages/configuration.yaml, line 28: required key not provided @ data['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 @ data['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",
|
||||||
])
|
])
|
||||||
# ---
|
# ---
|
||||||
# name: test_component_config_validation_error[packages_include_dir_named]
|
# name: test_component_config_validation_error[packages_include_dir_named]
|
||||||
list([
|
list([
|
||||||
"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 7: expected str for dictionary value @ data['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 6: required key not provided @ data['platform']. Got None.",
|
||||||
"Invalid config for [iot_domain] at <BASE_PATH>/fixtures/core/config/component_validation/packages_include_dir_named/integrations/iot_domain.yaml, line 9: required key not provided @ data['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 @ data['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 @ data['platform']. Got None.",
|
||||||
"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 @ data['adr_0007_2']['host']. Got None.",
|
"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 @ data['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 @ data['adr_0007_3']['port']. Got 'foo'.",
|
"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 @ data['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",
|
||||||
])
|
])
|
||||||
# ---
|
# ---
|
||||||
# name: test_package_merge_error[packages]
|
# name: test_package_merge_error[packages]
|
||||||
|
@ -133,7 +133,7 @@ async def mock_non_adr_0007_integration(hass) -> None:
|
|||||||
async def mock_adr_0007_integrations(hass) -> list[Integration]:
|
async def mock_adr_0007_integrations(hass) -> list[Integration]:
|
||||||
"""Mock ADR-0007 compliant integrations."""
|
"""Mock ADR-0007 compliant integrations."""
|
||||||
integrations = []
|
integrations = []
|
||||||
for domain in ["adr_0007_1", "adr_0007_2", "adr_0007_3"]:
|
for domain in ["adr_0007_1", "adr_0007_2", "adr_0007_3", "adr_0007_4"]:
|
||||||
adr_0007_config_schema = vol.Schema(
|
adr_0007_config_schema = vol.Schema(
|
||||||
{
|
{
|
||||||
domain: vol.Schema(
|
domain: vol.Schema(
|
||||||
@ -1498,7 +1498,13 @@ async def test_component_config_validation_error(
|
|||||||
)
|
)
|
||||||
config = await config_util.async_hass_config_yaml(hass)
|
config = await config_util.async_hass_config_yaml(hass)
|
||||||
|
|
||||||
for domain in ["iot_domain", "adr_0007_1", "adr_0007_2", "adr_0007_3"]:
|
for domain in [
|
||||||
|
"iot_domain",
|
||||||
|
"adr_0007_1",
|
||||||
|
"adr_0007_2",
|
||||||
|
"adr_0007_3",
|
||||||
|
"adr_0007_4",
|
||||||
|
]:
|
||||||
integration = await async_get_integration(hass, domain)
|
integration = await async_get_integration(hass, domain)
|
||||||
await config_util.async_process_component_config(
|
await config_util.async_process_component_config(
|
||||||
hass,
|
hass,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user