File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed
tests/components/steamist Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ """Test fixtures for the Steamist integration."""
2+
3+ from collections .abc import Generator
4+ from unittest .mock import AsyncMock , MagicMock , patch
5+
6+ import pytest
7+
8+
9+ @pytest .fixture
10+ def mock_aio_discovery () -> Generator [MagicMock ]:
11+ """Mock AIODiscovery30303."""
12+ with patch (
13+ "homeassistant.components.steamist.discovery.AIODiscovery30303"
14+ ) as mock_aio_discovery :
15+ mock_aio_discovery .return_value .async_scan = AsyncMock ()
16+ yield mock_aio_discovery
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ def mock_single_broadcast_address():
4242 yield
4343
4444
45+ @pytest .mark .usefixtures ("mock_aio_discovery" )
4546async def test_config_entry_reload (hass : HomeAssistant ) -> None :
4647 """Test that a config entry can be reloaded."""
4748 _ , config_entry = await _async_setup_entry_with_status (
@@ -52,6 +53,7 @@ async def test_config_entry_reload(hass: HomeAssistant) -> None:
5253 assert config_entry .state is ConfigEntryState .NOT_LOADED
5354
5455
56+ @pytest .mark .usefixtures ("mock_aio_discovery" )
5557async def test_config_entry_retry_later (hass : HomeAssistant ) -> None :
5658 """Test that a config entry retry on connection error."""
5759 config_entry = MockConfigEntry (
Original file line number Diff line number Diff line change 22
33from __future__ import annotations
44
5+ import pytest
6+
57from homeassistant .const import ATTR_UNIT_OF_MEASUREMENT , UnitOfTemperature , UnitOfTime
68from homeassistant .core import HomeAssistant
79
1214)
1315
1416
17+ @pytest .mark .usefixtures ("mock_aio_discovery" )
1518async def test_steam_active (hass : HomeAssistant ) -> None :
1619 """Test that the sensors are setup with the expected values when steam is active."""
1720 await _async_setup_entry_with_status (hass , MOCK_ASYNC_GET_STATUS_ACTIVE )
@@ -23,6 +26,7 @@ async def test_steam_active(hass: HomeAssistant) -> None:
2326 assert state .attributes [ATTR_UNIT_OF_MEASUREMENT ] == UnitOfTime .MINUTES
2427
2528
29+ @pytest .mark .usefixtures ("mock_aio_discovery" )
2630async def test_steam_inactive (hass : HomeAssistant ) -> None :
2731 """Test that the sensors are setup with the expected values when steam is not active."""
2832 await _async_setup_entry_with_status (hass , MOCK_ASYNC_GET_STATUS_INACTIVE )
Original file line number Diff line number Diff line change 55from datetime import timedelta
66from unittest .mock import AsyncMock
77
8+ import pytest
9+
810from homeassistant .components .switch import DOMAIN as SWITCH_DOMAIN
911from homeassistant .const import ATTR_ENTITY_ID , STATE_OFF , STATE_ON
1012from homeassistant .core import HomeAssistant
1921from tests .common import async_fire_time_changed
2022
2123
24+ @pytest .mark .usefixtures ("mock_aio_discovery" )
2225async def test_steam_active (hass : HomeAssistant ) -> None :
2326 """Test that the switches are setup with the expected values when steam is active."""
2427 client , _ = await _async_setup_entry_with_status (hass , MOCK_ASYNC_GET_STATUS_ACTIVE )
@@ -38,6 +41,7 @@ async def test_steam_active(hass: HomeAssistant) -> None:
3841 assert hass .states .get ("switch.steam_active" ).state == STATE_OFF
3942
4043
44+ @pytest .mark .usefixtures ("mock_aio_discovery" )
4145async def test_steam_inactive (hass : HomeAssistant ) -> None :
4246 """Test that the switches are setup with the expected values when steam is not active."""
4347 client , _ = await _async_setup_entry_with_status (
You can’t perform that action at this time.
0 commit comments