mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Use snapshot testing in Brother sensor (#115875)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
This commit is contained in:
parent
c2450c1112
commit
c4e7a7af21
1394
tests/components/brother/snapshots/test_sensor.ambr
Normal file
1394
tests/components/brother/snapshots/test_sensor.ambr
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,389 +1,46 @@
|
|||||||
"""Test sensor of Brother integration."""
|
"""Test sensor of Brother integration."""
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import timedelta
|
||||||
import json
|
import json
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.brother.const import DOMAIN
|
from homeassistant.components.brother.const import DOMAIN
|
||||||
from homeassistant.components.brother.sensor import UNIT_PAGES
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, Platform
|
||||||
ATTR_STATE_CLASS,
|
|
||||||
DOMAIN as SENSOR_DOMAIN,
|
|
||||||
SensorDeviceClass,
|
|
||||||
SensorStateClass,
|
|
||||||
)
|
|
||||||
from homeassistant.const import (
|
|
||||||
ATTR_DEVICE_CLASS,
|
|
||||||
ATTR_ENTITY_ID,
|
|
||||||
ATTR_ICON,
|
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
|
||||||
PERCENTAGE,
|
|
||||||
STATE_UNAVAILABLE,
|
|
||||||
)
|
|
||||||
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
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util.dt import UTC, utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
from . import init_integration
|
from . import init_integration
|
||||||
|
|
||||||
from tests.common import async_fire_time_changed, load_fixture
|
from tests.common import async_fire_time_changed, load_fixture
|
||||||
|
|
||||||
ATTR_REMAINING_PAGES = "remaining_pages"
|
|
||||||
ATTR_COUNTER = "counter"
|
|
||||||
|
|
||||||
|
async def test_sensors(
|
||||||
async def test_sensors(hass: HomeAssistant, entity_registry: er.EntityRegistry) -> None:
|
hass: HomeAssistant,
|
||||||
"""Test states of the sensors."""
|
entity_registry: er.EntityRegistry,
|
||||||
entry = await init_integration(hass, skip_setup=True)
|
entity_registry_enabled_by_default: None,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
# Pre-create registry entries for disabled by default sensors
|
freezer: FrozenDateTimeFactory,
|
||||||
entity_registry.async_get_or_create(
|
|
||||||
SENSOR_DOMAIN,
|
|
||||||
DOMAIN,
|
|
||||||
"0123456789_uptime",
|
|
||||||
suggested_object_id="hl_l2340dw_last_restart",
|
|
||||||
disabled_by=None,
|
|
||||||
)
|
|
||||||
test_time = datetime(2019, 11, 11, 9, 10, 32, tzinfo=UTC)
|
|
||||||
with (
|
|
||||||
patch("brother.Brother.initialize"),
|
|
||||||
patch("brother.datetime", now=Mock(return_value=test_time)),
|
|
||||||
patch(
|
|
||||||
"brother.Brother._get_data",
|
|
||||||
return_value=json.loads(load_fixture("printer_data.json", "brother")),
|
|
||||||
),
|
|
||||||
):
|
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_status")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.state == "waiting"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is None
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_status")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_status"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_black_toner_remaining")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "75"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_black_toner_remaining")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_black_toner_remaining"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_cyan_toner_remaining")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "10"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_cyan_toner_remaining")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_cyan_toner_remaining"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_magenta_toner_remaining")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "8"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_magenta_toner_remaining")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_magenta_toner_remaining"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_yellow_toner_remaining")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "2"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_yellow_toner_remaining")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_yellow_toner_remaining"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_drum_remaining_lifetime")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "92"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_drum_remaining_lifetime")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_drum_remaining_life"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_drum_remaining_pages")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "11014"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_drum_remaining_pages")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_drum_remaining_pages"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_drum_page_counter")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "986"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_drum_page_counter")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_drum_counter"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_black_drum_remaining_lifetime")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "92"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_black_drum_remaining_lifetime")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_black_drum_remaining_life"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_black_drum_remaining_pages")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "16389"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_black_drum_remaining_pages")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_black_drum_remaining_pages"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_black_drum_page_counter")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "1611"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_black_drum_page_counter")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_black_drum_counter"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_cyan_drum_remaining_lifetime")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "92"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_cyan_drum_remaining_lifetime")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_cyan_drum_remaining_life"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_cyan_drum_remaining_pages")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "16389"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_cyan_drum_remaining_pages")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_cyan_drum_remaining_pages"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_cyan_drum_page_counter")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "1611"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_cyan_drum_page_counter")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_cyan_drum_counter"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_magenta_drum_remaining_lifetime")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "92"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get(
|
|
||||||
"sensor.hl_l2340dw_magenta_drum_remaining_lifetime"
|
|
||||||
)
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_magenta_drum_remaining_life"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_magenta_drum_remaining_pages")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "16389"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_magenta_drum_remaining_pages")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_magenta_drum_remaining_pages"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_magenta_drum_page_counter")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "1611"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_magenta_drum_page_counter")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_magenta_drum_counter"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_yellow_drum_remaining_lifetime")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "92"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get(
|
|
||||||
"sensor.hl_l2340dw_yellow_drum_remaining_lifetime"
|
|
||||||
)
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_yellow_drum_remaining_life"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_yellow_drum_remaining_pages")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "16389"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_yellow_drum_remaining_pages")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_yellow_drum_remaining_pages"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_yellow_drum_page_counter")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "1611"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_yellow_drum_page_counter")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_yellow_drum_counter"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_fuser_remaining_lifetime")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "97"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_fuser_remaining_lifetime")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_fuser_remaining_life"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_belt_unit_remaining_lifetime")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "97"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_belt_unit_remaining_lifetime")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_belt_unit_remaining_life"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_pf_kit_1_remaining_lifetime")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
|
||||||
assert state.state == "98"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_pf_kit_1_remaining_lifetime")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_pf_kit_1_remaining_life"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_page_counter")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "986"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_page_counter")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_page_counter"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_duplex_unit_page_counter")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "538"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_duplex_unit_page_counter")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_duplex_unit_pages_counter"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_b_w_pages")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "709"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_b_w_pages")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_bw_counter"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_color_pages")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UNIT_PAGES
|
|
||||||
assert state.state == "902"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_color_pages")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_color_counter"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_last_restart")
|
|
||||||
assert state
|
|
||||||
assert state.attributes.get(ATTR_ICON) is None
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP
|
|
||||||
assert state.state == "2019-09-24T12:14:56+00:00"
|
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is None
|
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_last_restart")
|
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_uptime"
|
|
||||||
|
|
||||||
|
|
||||||
async def test_disabled_by_default_sensors(
|
|
||||||
hass: HomeAssistant, entity_registry: er.EntityRegistry
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the disabled by default Brother sensors."""
|
"""Test states of the sensors."""
|
||||||
await init_integration(hass)
|
hass.config.set_time_zone("UTC")
|
||||||
|
freezer.move_to("2024-04-20 12:00:00+00:00")
|
||||||
|
|
||||||
state = hass.states.get("sensor.hl_l2340dw_last_restart")
|
with patch("homeassistant.components.brother.PLATFORMS", [Platform.SENSOR]):
|
||||||
assert state is None
|
entry = await init_integration(hass)
|
||||||
|
|
||||||
entry = entity_registry.async_get("sensor.hl_l2340dw_last_restart")
|
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
|
||||||
assert entry
|
|
||||||
assert entry.unique_id == "0123456789_uptime"
|
assert entity_entries
|
||||||
assert entry.disabled
|
for entity_entry in entity_entries:
|
||||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")
|
||||||
|
assert (state := hass.states.get(entity_entry.entity_id))
|
||||||
|
assert state == snapshot(name=f"{entity_entry.entity_id}-state")
|
||||||
|
|
||||||
|
|
||||||
async def test_availability(hass: HomeAssistant) -> None:
|
async def test_availability(hass: HomeAssistant) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user