Use setup_test_component_platform
helper for update entity component tests instead of hass.components
(#114203)
* Use `setup_test_component_platform` helper for update entity component tests instead of `hass.components` * Run ruff format
This commit is contained in:
parent
9a1906322b
commit
dce3bde0ab
6 changed files with 190 additions and 217 deletions
|
@ -50,6 +50,7 @@ from tests.common import (
|
|||
mock_integration,
|
||||
mock_platform,
|
||||
mock_restore_cache,
|
||||
setup_test_component_platform,
|
||||
)
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
|
@ -166,11 +167,10 @@ async def test_update(hass: HomeAssistant) -> None:
|
|||
|
||||
async def test_entity_with_no_install(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
) -> None:
|
||||
"""Test entity with no updates."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -232,11 +232,10 @@ async def test_entity_with_no_install(
|
|||
|
||||
async def test_entity_with_no_updates(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
) -> None:
|
||||
"""Test entity with no updates."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -281,12 +280,11 @@ async def test_entity_with_no_updates(
|
|||
|
||||
async def test_entity_with_auto_update(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update entity that has auto update feature."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -333,12 +331,11 @@ async def test_entity_with_auto_update(
|
|||
|
||||
async def test_entity_with_updates_available(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test basic update entity with updates available."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -387,12 +384,11 @@ async def test_entity_with_updates_available(
|
|||
|
||||
async def test_entity_with_unknown_version(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update entity that has an unknown version."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -425,12 +421,11 @@ async def test_entity_with_unknown_version(
|
|||
|
||||
async def test_entity_with_specific_version(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update entity that support specific version."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -488,12 +483,11 @@ async def test_entity_with_specific_version(
|
|||
|
||||
async def test_entity_with_backup_support(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update entity with backup support."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -548,12 +542,11 @@ async def test_entity_with_backup_support(
|
|||
|
||||
async def test_entity_already_in_progress(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update install already in progress."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -579,15 +572,14 @@ async def test_entity_already_in_progress(
|
|||
|
||||
async def test_entity_without_progress_support(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update entity without progress support.
|
||||
|
||||
In that case, progress is still handled by Home Assistant.
|
||||
"""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -618,15 +610,14 @@ async def test_entity_without_progress_support(
|
|||
|
||||
async def test_entity_without_progress_support_raising(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update entity without progress support that raises during install.
|
||||
|
||||
In that case, progress is still handled by Home Assistant.
|
||||
"""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -665,7 +656,7 @@ async def test_entity_without_progress_support_raising(
|
|||
|
||||
|
||||
async def test_restore_state(
|
||||
hass: HomeAssistant, enable_custom_integrations: None
|
||||
hass: HomeAssistant, mock_update_entities: list[MockUpdateEntity]
|
||||
) -> None:
|
||||
"""Test we restore skipped version state."""
|
||||
mock_restore_cache(
|
||||
|
@ -681,8 +672,7 @@ async def test_restore_state(
|
|||
),
|
||||
)
|
||||
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -697,12 +687,11 @@ async def test_restore_state(
|
|||
|
||||
async def test_release_notes(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
) -> None:
|
||||
"""Test getting the release notes over the websocket connection."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -723,12 +712,11 @@ async def test_release_notes(
|
|||
|
||||
async def test_release_notes_entity_not_found(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
) -> None:
|
||||
"""Test getting the release notes for not found entity."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
@ -750,12 +738,11 @@ async def test_release_notes_entity_not_found(
|
|||
|
||||
async def test_release_notes_entity_does_not_support_release_notes(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
mock_update_entities: list[MockUpdateEntity],
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
) -> None:
|
||||
"""Test getting the release notes for entity that does not support release notes."""
|
||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, DOMAIN, mock_update_entities)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue