Cherry pick test fix (#22939)
This commit is contained in:
parent
58ec77b017
commit
c82d2cb11c
9 changed files with 41 additions and 19 deletions
|
@ -444,6 +444,7 @@ class MockModule:
|
|||
async_migrate_entry=None, async_remove_entry=None):
|
||||
"""Initialize the mock module."""
|
||||
self.__name__ = 'homeassistant.components.{}'.format(domain)
|
||||
self.__file__ = 'homeassistant/components/{}'.format(domain)
|
||||
self.DOMAIN = domain
|
||||
self.DEPENDENCIES = dependencies or []
|
||||
self.REQUIREMENTS = requirements or []
|
||||
|
@ -483,7 +484,8 @@ class MockModule:
|
|||
class MockPlatform:
|
||||
"""Provide a fake platform."""
|
||||
|
||||
__name__ = "homeassistant.components.light.bla"
|
||||
__name__ = 'homeassistant.components.light.bla'
|
||||
__file__ = 'homeassistant/components/blah/light'
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
def __init__(self, setup_platform=None, dependencies=None,
|
||||
|
@ -694,13 +696,15 @@ def assert_setup_component(count, domain=None):
|
|||
config = {}
|
||||
|
||||
@ha.callback
|
||||
def mock_psc(hass, config_input, domain):
|
||||
def mock_psc(hass, config_input, domain_input):
|
||||
"""Mock the prepare_setup_component to capture config."""
|
||||
res = async_process_component_config(
|
||||
hass, config_input, domain)
|
||||
config[domain] = None if res is None else res.get(domain)
|
||||
hass, config_input, domain_input)
|
||||
config[domain_input] = None if res is None else res.get(domain_input)
|
||||
_LOGGER.debug("Configuration for %s, Validated: %s, Original %s",
|
||||
domain, config[domain], config_input.get(domain))
|
||||
domain_input,
|
||||
config[domain_input],
|
||||
config_input.get(domain_input))
|
||||
return res
|
||||
|
||||
assert isinstance(config, dict)
|
||||
|
@ -709,7 +713,7 @@ def assert_setup_component(count, domain=None):
|
|||
yield config
|
||||
|
||||
if domain is None:
|
||||
assert len(config) >= 1, ('assert_setup_component requires DOMAIN: {}'
|
||||
assert len(config) == 1, ('assert_setup_component requires DOMAIN: {}'
|
||||
.format(list(config.keys())))
|
||||
domain = list(config.keys())[0]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue