Migrate Moon to new entity naming style (#75085)
This commit is contained in:
parent
3d31e62683
commit
0e59e8b925
2 changed files with 21 additions and 5 deletions
|
@ -16,9 +16,9 @@ from homeassistant.components.moon.sensor import (
|
|||
STATE_WAXING_CRESCENT,
|
||||
STATE_WAXING_GIBBOUS,
|
||||
)
|
||||
from homeassistant.const import ATTR_ICON
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_ICON
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -52,12 +52,20 @@ async def test_moon_day(
|
|||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.moon")
|
||||
state = hass.states.get("sensor.moon_phase")
|
||||
assert state
|
||||
assert state.state == native_value
|
||||
assert state.attributes[ATTR_ICON] == icon
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "Moon Phase"
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
entry = entity_registry.async_get("sensor.moon")
|
||||
entry = entity_registry.async_get("sensor.moon_phase")
|
||||
assert entry
|
||||
assert entry.unique_id == mock_config_entry.entry_id
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
assert entry.device_id
|
||||
device_entry = device_registry.async_get(entry.device_id)
|
||||
assert device_entry
|
||||
assert device_entry.name == "Moon"
|
||||
assert device_entry.entry_type is dr.DeviceEntryType.SERVICE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue