mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Use setup_test_component_platform helper for sensor entity component tests instead of hass.components (#114316)
* Use `setup_test_component_platform` helper for sensor entity component tests instead of `hass.components` * Missing file * Fix import * Remove invalid device class
This commit is contained in:
committed by
GitHub
parent
41bd3d0853
commit
22b14d83e8
@@ -1461,7 +1461,10 @@ def mock_integration(
|
||||
|
||||
|
||||
def mock_platform(
|
||||
hass: HomeAssistant, platform_path: str, module: Mock | MockPlatform | None = None
|
||||
hass: HomeAssistant,
|
||||
platform_path: str,
|
||||
module: Mock | MockPlatform | None = None,
|
||||
built_in=True,
|
||||
) -> None:
|
||||
"""Mock a platform.
|
||||
|
||||
@@ -1472,7 +1475,7 @@ def mock_platform(
|
||||
module_cache = hass.data[loader.DATA_COMPONENTS]
|
||||
|
||||
if domain not in integration_cache:
|
||||
mock_integration(hass, MockModule(domain))
|
||||
mock_integration(hass, MockModule(domain), built_in=built_in)
|
||||
|
||||
integration_cache[domain]._top_level_files.add(f"{platform_name}.py")
|
||||
_LOGGER.info("Adding mock integration platform: %s", platform_path)
|
||||
@@ -1665,6 +1668,7 @@ def setup_test_component_platform(
|
||||
domain: str,
|
||||
entities: Sequence[Entity],
|
||||
from_config_entry: bool = False,
|
||||
built_in: bool = True,
|
||||
) -> MockPlatform:
|
||||
"""Mock a test component platform for tests."""
|
||||
|
||||
@@ -1695,9 +1699,5 @@ def setup_test_component_platform(
|
||||
platform.async_setup_entry = _async_setup_entry
|
||||
platform.async_setup_platform = None
|
||||
|
||||
mock_platform(
|
||||
hass,
|
||||
f"test.{domain}",
|
||||
platform,
|
||||
)
|
||||
mock_platform(hass, f"test.{domain}", platform, built_in=built_in)
|
||||
return platform
|
||||
|
||||
Reference in New Issue
Block a user