mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +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.model.node.data_model import NodeDataType
|
||||||
from zwave_js_server.version import VersionInfo
|
from zwave_js_server.version import VersionInfo
|
||||||
|
|
||||||
|
from homeassistant.components.zwave_js import PLATFORMS
|
||||||
from homeassistant.components.zwave_js.const import DOMAIN
|
from homeassistant.components.zwave_js.const import DOMAIN
|
||||||
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.util.json import JsonArrayType
|
from homeassistant.util.json import JsonArrayType
|
||||||
|
|
||||||
@ -828,18 +830,26 @@ def nortek_thermostat_removed_event_fixture(client) -> Node:
|
|||||||
async def integration_fixture(
|
async def integration_fixture(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
client: MagicMock,
|
client: MagicMock,
|
||||||
|
platforms: list[Platform],
|
||||||
) -> MockConfigEntry:
|
) -> MockConfigEntry:
|
||||||
"""Set up the zwave_js integration."""
|
"""Set up the zwave_js integration."""
|
||||||
entry = MockConfigEntry(domain="zwave_js", data={"url": "ws://test.org"})
|
entry = MockConfigEntry(domain="zwave_js", data={"url": "ws://test.org"})
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
with patch("homeassistant.components.zwave_js.PLATFORMS", platforms):
|
||||||
await hass.async_block_till_done()
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
client.async_send_command.reset_mock()
|
client.async_send_command.reset_mock()
|
||||||
|
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def platforms() -> list[Platform]:
|
||||||
|
"""Fixture to specify platforms to test."""
|
||||||
|
return PLATFORMS
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="chain_actuator_zws12")
|
@pytest.fixture(name="chain_actuator_zws12")
|
||||||
def window_cover_fixture(client, chain_actuator_zws12_state) -> Node:
|
def window_cover_fixture(client, chain_actuator_zws12_state) -> Node:
|
||||||
"""Mock a window cover node."""
|
"""Mock a window cover node."""
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Test the Z-Wave JS siren platform."""
|
"""Test the Z-Wave JS siren platform."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
from zwave_js_server.event import Event
|
from zwave_js_server.event import Event
|
||||||
|
|
||||||
from homeassistant.components.siren import (
|
from homeassistant.components.siren import (
|
||||||
@ -7,7 +8,7 @@ from homeassistant.components.siren import (
|
|||||||
ATTR_TONE,
|
ATTR_TONE,
|
||||||
ATTR_VOLUME_LEVEL,
|
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
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
SIREN_ENTITY = "siren.indoor_siren_6_play_tone_2"
|
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(
|
async def test_siren(
|
||||||
hass: HomeAssistant, client, aeotec_zw164_siren, integration
|
hass: HomeAssistant, client, aeotec_zw164_siren, integration
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user