No longer allow invalid slugs or extra keys (#24176)
* No longer allow slugs * Lint * Remove HASchema * Lint * Fix tests
This commit is contained in:
parent
b3d8f8620c
commit
59ce31f44f
6 changed files with 8 additions and 275 deletions
|
@ -108,37 +108,6 @@ class TestSetup:
|
|||
'platform_conf.whatever',
|
||||
MockPlatform(platform_schema=platform_schema))
|
||||
|
||||
with assert_setup_component(1):
|
||||
assert setup.setup_component(self.hass, 'platform_conf', {
|
||||
'platform_conf': {
|
||||
'platform': 'whatever',
|
||||
'hello': 'world',
|
||||
'invalid': 'extra',
|
||||
}
|
||||
})
|
||||
assert caplog.text.count('Your configuration contains '
|
||||
'extra keys') == 1
|
||||
|
||||
self.hass.data.pop(setup.DATA_SETUP)
|
||||
self.hass.config.components.remove('platform_conf')
|
||||
|
||||
with assert_setup_component(2):
|
||||
assert setup.setup_component(self.hass, 'platform_conf', {
|
||||
'platform_conf': {
|
||||
'platform': 'whatever',
|
||||
'hello': 'world',
|
||||
},
|
||||
'platform_conf 2': {
|
||||
'platform': 'whatever',
|
||||
'invalid': True
|
||||
}
|
||||
})
|
||||
assert caplog.text.count('Your configuration contains '
|
||||
'extra keys') == 2
|
||||
|
||||
self.hass.data.pop(setup.DATA_SETUP)
|
||||
self.hass.config.components.remove('platform_conf')
|
||||
|
||||
with assert_setup_component(0):
|
||||
assert setup.setup_component(self.hass, 'platform_conf', {
|
||||
'platform_conf': {
|
||||
|
@ -206,21 +175,6 @@ class TestSetup:
|
|||
MockPlatform('whatever',
|
||||
platform_schema=platform_schema))
|
||||
|
||||
with assert_setup_component(1):
|
||||
assert setup.setup_component(self.hass, 'platform_conf', {
|
||||
# fail: no extra keys allowed in platform schema
|
||||
'platform_conf': {
|
||||
'platform': 'whatever',
|
||||
'hello': 'world',
|
||||
'invalid': 'extra',
|
||||
}
|
||||
})
|
||||
assert caplog.text.count('Your configuration contains '
|
||||
'extra keys') == 1
|
||||
|
||||
self.hass.data.pop(setup.DATA_SETUP)
|
||||
self.hass.config.components.remove('platform_conf')
|
||||
|
||||
with assert_setup_component(1):
|
||||
assert setup.setup_component(self.hass, 'platform_conf', {
|
||||
# pass
|
||||
|
@ -235,9 +189,6 @@ class TestSetup:
|
|||
}
|
||||
})
|
||||
|
||||
self.hass.data.pop(setup.DATA_SETUP)
|
||||
self.hass.config.components.remove('platform_conf')
|
||||
|
||||
def test_validate_platform_config_3(self, caplog):
|
||||
"""Test fallback to component PLATFORM_SCHEMA."""
|
||||
component_schema = PLATFORM_SCHEMA_BASE.extend({
|
||||
|
@ -258,20 +209,6 @@ class TestSetup:
|
|||
MockPlatform('whatever',
|
||||
platform_schema=platform_schema))
|
||||
|
||||
with assert_setup_component(1):
|
||||
assert setup.setup_component(self.hass, 'platform_conf', {
|
||||
'platform_conf': {
|
||||
'platform': 'whatever',
|
||||
'hello': 'world',
|
||||
'invalid': 'extra',
|
||||
}
|
||||
})
|
||||
assert caplog.text.count('Your configuration contains '
|
||||
'extra keys') == 1
|
||||
|
||||
self.hass.data.pop(setup.DATA_SETUP)
|
||||
self.hass.config.components.remove('platform_conf')
|
||||
|
||||
with assert_setup_component(1):
|
||||
assert setup.setup_component(self.hass, 'platform_conf', {
|
||||
# pass
|
||||
|
@ -286,9 +223,6 @@ class TestSetup:
|
|||
}
|
||||
})
|
||||
|
||||
self.hass.data.pop(setup.DATA_SETUP)
|
||||
self.hass.config.components.remove('platform_conf')
|
||||
|
||||
def test_validate_platform_config_4(self):
|
||||
"""Test entity_namespace in PLATFORM_SCHEMA."""
|
||||
component_schema = PLATFORM_SCHEMA_BASE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue