Load requirements and dependencies from manifests. Fallback to current REQUIREMENTS
and DEPENDENCIES
(#22717)
* Load dependencies from manifests. Fallback to current DEPENDENCIES * Fix typing * Ignore typing correctly * Split out dependency processing to a new method * Fix tests * Only pull from manifest if dependencies is non empty * Inline temporary function * Fix light tests [skip ci] * Fix tests/common * Fix some mqtt tests [skip ci] * Fix tests and component manifests which have only one platform * Fix rflink tests * Fix more tests and manifests * Readability over shorthand format * Fix demo/notify tests * Load dependencies from manifests. Fallback to current DEPENDENCIES * Load requirements from manifests. Fallback to current REQUIREMENTS * Fix typing * Ignore typing correctly * Split out dependency processing to a new method * Only pull from manifest if dependencies is non empty * Inline temporary function * Fix tests and component manifests which have only one platform * Fix rflink tests * Readability over shorthand format * Clean up requirements * Use integration to resolve deps/reqs * Lint * Lint * revert a change * Revert a test change * Fix types * Fix types * Add back cache for load component * Fix test_component_not_found * Move light.test and device_tracker.test into test package instead with manifest to fix tests * Fix broken device_tracker tests * Add docstrings to __init__ * Fix all of the light tests that I broke earlier * Embed the test.switch platform to fix other tests * Embed and fix the test.imagimage_processing platform * Fix tests for nx584 * Add dependencies from platform file's DEPENDENCIES * Try to setup component when entity_platform is setting up Fix tests in helpers folder * Rewrite test_setup * Simplify * Lint * Disable demo component if running in test Temp workaround to unblock CI tests * Skip demo tests * Fix config entry test * Fix repeat test * Clarify doc * One extra guard * Fix import * Lint * Workaround google tts
This commit is contained in:
parent
8a81286abb
commit
6ba9ccf052
66 changed files with 391 additions and 233 deletions
|
@ -8,7 +8,6 @@ from datetime import timedelta
|
|||
import pytest
|
||||
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
import homeassistant.loader as loader
|
||||
from homeassistant.helpers.entity import generate_entity_id
|
||||
from homeassistant.helpers.entity_component import (
|
||||
EntityComponent, DEFAULT_SCAN_INTERVAL)
|
||||
|
@ -18,7 +17,7 @@ import homeassistant.util.dt as dt_util
|
|||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, MockPlatform, fire_time_changed, mock_registry,
|
||||
MockEntity, MockEntityPlatform, MockConfigEntry)
|
||||
MockEntity, MockEntityPlatform, MockConfigEntry, mock_entity_platform)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
DOMAIN = "test_domain"
|
||||
|
@ -149,7 +148,7 @@ class TestHelpersEntityPlatform(unittest.TestCase):
|
|||
platform = MockPlatform(platform_setup)
|
||||
platform.SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
loader.set_component(self.hass, 'test_domain.platform', platform)
|
||||
mock_entity_platform(self.hass, 'test_domain.platform', platform)
|
||||
|
||||
component = EntityComponent(_LOGGER, DOMAIN, self.hass)
|
||||
|
||||
|
@ -186,7 +185,7 @@ def test_platform_warn_slow_setup(hass):
|
|||
"""Warn we log when platform setup takes a long time."""
|
||||
platform = MockPlatform()
|
||||
|
||||
loader.set_component(hass, 'test_domain.platform', platform)
|
||||
mock_entity_platform(hass, 'test_domain.platform', platform)
|
||||
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
|
||||
|
@ -199,7 +198,9 @@ def test_platform_warn_slow_setup(hass):
|
|||
})
|
||||
assert mock_call.called
|
||||
|
||||
timeout, logger_method = mock_call.mock_calls[0][1][:2]
|
||||
# mock_calls[0] is the warning message for component setup
|
||||
# mock_calls[3] is the warning message for platform setup
|
||||
timeout, logger_method = mock_call.mock_calls[3][1][:2]
|
||||
|
||||
assert timeout == entity_platform.SLOW_SETUP_WARNING
|
||||
assert logger_method == _LOGGER.warning
|
||||
|
@ -220,7 +221,7 @@ def test_platform_error_slow_setup(hass, caplog):
|
|||
|
||||
platform = MockPlatform(async_setup_platform=setup_platform)
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
loader.set_component(hass, 'test_domain.test_platform', platform)
|
||||
mock_entity_platform(hass, 'test_domain.test_platform', platform)
|
||||
yield from component.async_setup({
|
||||
DOMAIN: {
|
||||
'platform': 'test_platform',
|
||||
|
@ -255,7 +256,7 @@ async def test_parallel_updates_async_platform(hass):
|
|||
"""Test async platform does not have parallel_updates limit by default."""
|
||||
platform = MockPlatform()
|
||||
|
||||
loader.set_component(hass, 'test_domain.platform', platform)
|
||||
mock_entity_platform(hass, 'test_domain.platform', platform)
|
||||
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
component._platforms = {}
|
||||
|
@ -285,7 +286,7 @@ async def test_parallel_updates_async_platform_with_constant(hass):
|
|||
platform = MockPlatform()
|
||||
platform.PARALLEL_UPDATES = 2
|
||||
|
||||
loader.set_component(hass, 'test_domain.platform', platform)
|
||||
mock_entity_platform(hass, 'test_domain.platform', platform)
|
||||
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
component._platforms = {}
|
||||
|
@ -316,7 +317,7 @@ async def test_parallel_updates_sync_platform(hass):
|
|||
"""Test sync platform parallel_updates default set to 1."""
|
||||
platform = MockPlatform()
|
||||
|
||||
loader.set_component(hass, 'test_domain.platform', platform)
|
||||
mock_entity_platform(hass, 'test_domain.platform', platform)
|
||||
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
component._platforms = {}
|
||||
|
@ -347,7 +348,7 @@ async def test_parallel_updates_sync_platform_with_constant(hass):
|
|||
platform = MockPlatform()
|
||||
platform.PARALLEL_UPDATES = 2
|
||||
|
||||
loader.set_component(hass, 'test_domain.platform', platform)
|
||||
mock_entity_platform(hass, 'test_domain.platform', platform)
|
||||
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
component._platforms = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue