Use setup_test_component_platform func for cover entity component tests instead of hass.components (#114010)

* Use `mock_platform` for cover entity component tests instead of `hass.components`

* Remove setup fixture and use helper function

* Remove is_on from MockCover

* Run ruff

* Do not override state in `MockCover` in cover tests

* Remove is_on from MockCover
This commit is contained in:
Jan-Philipp Benecke 2024-03-27 12:20:19 +01:00 committed by GitHub
parent 3929273b41
commit 34cf0c5721
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 241 additions and 274 deletions

View file

@ -17,14 +17,21 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from tests.common import help_test_all, import_and_test_deprecated_constant_enum
from tests.common import (
help_test_all,
import_and_test_deprecated_constant_enum,
setup_test_component_platform,
)
from tests.components.cover.common import MockCover
async def test_services(hass: HomeAssistant, enable_custom_integrations: None) -> None:
async def test_services(
hass: HomeAssistant,
mock_cover_entities: list[MockCover],
) -> None:
"""Test the provided services."""
platform = getattr(hass.components, "test.cover")
setup_test_component_platform(hass, cover.DOMAIN, mock_cover_entities)
platform.init()
assert await async_setup_component(
hass, cover.DOMAIN, {cover.DOMAIN: {CONF_PLATFORM: "test"}}
)
@ -36,7 +43,7 @@ async def test_services(hass: HomeAssistant, enable_custom_integrations: None) -
# ent4 = cover with all tilt functions but no position
# ent5 = cover with all functions
# ent6 = cover with only open/close, but also reports opening/closing
ent1, ent2, ent3, ent4, ent5, ent6 = platform.ENTITIES
ent1, ent2, ent3, ent4, ent5, ent6 = mock_cover_entities
# Test init all covers should be open
assert is_open(hass, ent1)