mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00

* Bring Nice G.O. up to platinum * Switch to listen in coordinator * Tests * Remove parallel updates from coordinator * Unsub from events on config entry unload * Detect WS disconnection * Tests * Fix tests * Set unsub to None after unsubbing * Wait 5 seconds before setting update error to prevent excessive errors * Tweaks * More tweaks * Tweaks part 2 * Potential test for hass stopping * Improve reconnect handling and test on Homeassistant stop event * Move event handler to entry init * Patch const instead of asyncio.sleep --------- Co-authored-by: jbouwh <jan@jbsoft.nl>
32 lines
906 B
Python
32 lines
906 B
Python
"""Nice G.O. event tests."""
|
|
|
|
from unittest.mock import AsyncMock, MagicMock
|
|
|
|
import pytest
|
|
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from . import setup_integration
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
@pytest.mark.freeze_time("2024-08-19")
|
|
async def test_barrier_obstructed(
|
|
hass: HomeAssistant,
|
|
mock_nice_go: AsyncMock,
|
|
mock_config_entry: MockConfigEntry,
|
|
) -> None:
|
|
"""Test barrier obstructed."""
|
|
mock_nice_go.listen = MagicMock()
|
|
await setup_integration(hass, mock_config_entry, [Platform.EVENT])
|
|
|
|
await mock_nice_go.listen.call_args_list[3][0][1]({"deviceId": "1"})
|
|
await hass.async_block_till_done()
|
|
|
|
event_state = hass.states.get("event.test_garage_1_barrier_obstructed")
|
|
|
|
assert event_state.state == "2024-08-19T00:00:00.000+00:00"
|
|
assert event_state.attributes["event_type"] == "barrier_obstructed"
|