mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 15:27:08 +00:00
Add 100% test coverage to WLED integration (#51743)
This commit is contained in:
parent
2a51587bc3
commit
b4aeddd12f
@ -551,6 +551,19 @@ async def test_preset_service(
|
|||||||
assert mock_wled.preset.call_count == 1
|
assert mock_wled.preset.call_count == 1
|
||||||
mock_wled.preset.assert_called_with(preset=1)
|
mock_wled.preset.assert_called_with(preset=1)
|
||||||
|
|
||||||
|
await hass.services.async_call(
|
||||||
|
DOMAIN,
|
||||||
|
SERVICE_PRESET,
|
||||||
|
{
|
||||||
|
ATTR_ENTITY_ID: "light.wled_rgb_light_master",
|
||||||
|
ATTR_PRESET: 2,
|
||||||
|
},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
assert mock_wled.preset.call_count == 2
|
||||||
|
mock_wled.preset.assert_called_with(preset=2)
|
||||||
|
|
||||||
|
|
||||||
async def test_preset_service_error(
|
async def test_preset_service_error(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
@ -23,6 +23,7 @@ from homeassistant.const import (
|
|||||||
DATA_BYTES,
|
DATA_BYTES,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
@ -196,3 +197,44 @@ async def test_disabled_by_default_sensors(
|
|||||||
assert entry
|
assert entry
|
||||||
assert entry.disabled
|
assert entry.disabled
|
||||||
assert entry.disabled_by == er.DISABLED_INTEGRATION
|
assert entry.disabled_by == er.DISABLED_INTEGRATION
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"key",
|
||||||
|
[
|
||||||
|
"bssid",
|
||||||
|
"channel",
|
||||||
|
"rssi",
|
||||||
|
"signal",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
async def test_no_wifi_support(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
mock_wled: MagicMock,
|
||||||
|
key: str,
|
||||||
|
) -> None:
|
||||||
|
"""Test missing Wi-Fi information from WLED device."""
|
||||||
|
registry = er.async_get(hass)
|
||||||
|
|
||||||
|
# Pre-create registry entries for disabled by default sensors
|
||||||
|
registry.async_get_or_create(
|
||||||
|
SENSOR_DOMAIN,
|
||||||
|
DOMAIN,
|
||||||
|
f"aabbccddeeff_wifi_{key}",
|
||||||
|
suggested_object_id=f"wled_rgb_light_wifi_{key}",
|
||||||
|
disabled_by=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Remove Wi-Fi info
|
||||||
|
device = mock_wled.update.return_value
|
||||||
|
device.info.wifi = None
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
state = hass.states.get(f"sensor.wled_rgb_light_wifi_{key}")
|
||||||
|
assert state
|
||||||
|
assert state.state == STATE_UNKNOWN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user