Fix demo (#23087)
* Fix demo * Fix types * Fix all the things * Fix type * Fix test * Lint
This commit is contained in:
parent
1d2e9b6915
commit
6b0180f753
20 changed files with 137 additions and 200 deletions
|
@ -317,7 +317,7 @@ class TestSetup:
|
|||
|
||||
def test_component_not_found(self):
|
||||
"""setup_component should not crash if component doesn't exist."""
|
||||
assert setup.setup_component(self.hass, 'non_existing') is False
|
||||
assert setup.setup_component(self.hass, 'non_existing', {}) is False
|
||||
|
||||
def test_component_not_double_initialized(self):
|
||||
"""Test we do not set up a component twice."""
|
||||
|
@ -327,12 +327,12 @@ class TestSetup:
|
|||
self.hass,
|
||||
MockModule('comp', setup=mock_setup))
|
||||
|
||||
assert setup.setup_component(self.hass, 'comp')
|
||||
assert setup.setup_component(self.hass, 'comp', {})
|
||||
assert mock_setup.called
|
||||
|
||||
mock_setup.reset_mock()
|
||||
|
||||
assert setup.setup_component(self.hass, 'comp')
|
||||
assert setup.setup_component(self.hass, 'comp', {})
|
||||
assert not mock_setup.called
|
||||
|
||||
@mock.patch('homeassistant.util.package.install_package',
|
||||
|
@ -344,7 +344,7 @@ class TestSetup:
|
|||
self.hass,
|
||||
MockModule('comp', requirements=['package==0.0.1']))
|
||||
|
||||
assert not setup.setup_component(self.hass, 'comp')
|
||||
assert not setup.setup_component(self.hass, 'comp', {})
|
||||
assert 'comp' not in self.hass.config.components
|
||||
|
||||
def test_component_not_setup_twice_if_loaded_during_other_setup(self):
|
||||
|
@ -362,11 +362,11 @@ class TestSetup:
|
|||
|
||||
def setup_component():
|
||||
"""Set up the component."""
|
||||
setup.setup_component(self.hass, 'comp')
|
||||
setup.setup_component(self.hass, 'comp', {})
|
||||
|
||||
thread = threading.Thread(target=setup_component)
|
||||
thread.start()
|
||||
setup.setup_component(self.hass, 'comp')
|
||||
setup.setup_component(self.hass, 'comp', {})
|
||||
|
||||
thread.join()
|
||||
|
||||
|
@ -493,7 +493,7 @@ class TestSetup:
|
|||
self.hass,
|
||||
MockModule('disabled_component', setup=lambda hass, config: None))
|
||||
|
||||
assert not setup.setup_component(self.hass, 'disabled_component')
|
||||
assert not setup.setup_component(self.hass, 'disabled_component', {})
|
||||
assert loader.get_component(self.hass, 'disabled_component') is None
|
||||
assert 'disabled_component' not in self.hass.config.components
|
||||
|
||||
|
@ -502,7 +502,7 @@ class TestSetup:
|
|||
self.hass,
|
||||
MockModule('disabled_component', setup=lambda hass, config: False))
|
||||
|
||||
assert not setup.setup_component(self.hass, 'disabled_component')
|
||||
assert not setup.setup_component(self.hass, 'disabled_component', {})
|
||||
assert loader.get_component(
|
||||
self.hass, 'disabled_component') is not None
|
||||
assert 'disabled_component' not in self.hass.config.components
|
||||
|
@ -512,7 +512,7 @@ class TestSetup:
|
|||
self.hass,
|
||||
MockModule('disabled_component', setup=lambda hass, config: True))
|
||||
|
||||
assert setup.setup_component(self.hass, 'disabled_component')
|
||||
assert setup.setup_component(self.hass, 'disabled_component', {})
|
||||
assert loader.get_component(
|
||||
self.hass, 'disabled_component') is not None
|
||||
assert 'disabled_component' in self.hass.config.components
|
||||
|
@ -523,10 +523,10 @@ class TestSetup:
|
|||
|
||||
def component1_setup(hass, config):
|
||||
"""Set up mock component."""
|
||||
discovery.discover(hass, 'test_component2',
|
||||
component='test_component2')
|
||||
discovery.discover(hass, 'test_component3',
|
||||
component='test_component3')
|
||||
discovery.discover(
|
||||
hass, 'test_component2', {}, 'test_component2', {})
|
||||
discovery.discover(
|
||||
hass, 'test_component3', {}, 'test_component3', {})
|
||||
return True
|
||||
|
||||
def component_track_setup(hass, config):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue