mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Allow patching Z-Wave platforms specifically in tests (#140987)
This commit is contained in:
parent
a20601a1f0
commit
d8a4a97ee0
@ -13,7 +13,9 @@ from zwave_js_server.model.node import Node
|
||||
from zwave_js_server.model.node.data_model import NodeDataType
|
||||
from zwave_js_server.version import VersionInfo
|
||||
|
||||
from homeassistant.components.zwave_js import PLATFORMS
|
||||
from homeassistant.components.zwave_js.const import DOMAIN
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
@ -828,18 +830,26 @@ def nortek_thermostat_removed_event_fixture(client) -> Node:
|
||||
async def integration_fixture(
|
||||
hass: HomeAssistant,
|
||||
client: MagicMock,
|
||||
platforms: list[Platform],
|
||||
) -> MockConfigEntry:
|
||||
"""Set up the zwave_js integration."""
|
||||
entry = MockConfigEntry(domain="zwave_js", data={"url": "ws://test.org"})
|
||||
entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
with patch("homeassistant.components.zwave_js.PLATFORMS", platforms):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
client.async_send_command.reset_mock()
|
||||
|
||||
return entry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[Platform]:
|
||||
"""Fixture to specify platforms to test."""
|
||||
return PLATFORMS
|
||||
|
||||
|
||||
@pytest.fixture(name="chain_actuator_zws12")
|
||||
def window_cover_fixture(client, chain_actuator_zws12_state) -> Node:
|
||||
"""Mock a window cover node."""
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Test the Z-Wave JS siren platform."""
|
||||
|
||||
import pytest
|
||||
from zwave_js_server.event import Event
|
||||
|
||||
from homeassistant.components.siren import (
|
||||
@ -7,7 +8,7 @@ from homeassistant.components.siren import (
|
||||
ATTR_TONE,
|
||||
ATTR_VOLUME_LEVEL,
|
||||
)
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
SIREN_ENTITY = "siren.indoor_siren_6_play_tone_2"
|
||||
@ -64,6 +65,12 @@ TONE_ID_VALUE_ID = {
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platforms() -> list[str]:
|
||||
"""Fixture to specify platforms to test."""
|
||||
return [Platform.SIREN]
|
||||
|
||||
|
||||
async def test_siren(
|
||||
hass: HomeAssistant, client, aeotec_zw164_siren, integration
|
||||
) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user