mirror of
https://github.com/home-assistant/core.git
synced 2026-09-13 20:20:10 +01:00
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""Tests for the OpenEVSE sensor platform."""
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
import pytest
|
|
from syrupy.assertion import SnapshotAssertion
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import entity_registry as er
|
|
|
|
from tests.common import MockConfigEntry, snapshot_platform
|
|
|
|
|
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
|
async def test_entities(
|
|
hass: HomeAssistant,
|
|
entity_registry: er.EntityRegistry,
|
|
snapshot: SnapshotAssertion,
|
|
mock_config_entry: MockConfigEntry,
|
|
mock_charger: MagicMock,
|
|
) -> None:
|
|
"""Test the sensor entities."""
|
|
mock_config_entry.add_to_hass(hass)
|
|
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
|
|
|
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
|
|
|
|
|
async def test_disabled_by_default_entities(
|
|
hass: HomeAssistant,
|
|
entity_registry: er.EntityRegistry,
|
|
mock_config_entry: MockConfigEntry,
|
|
mock_charger: MagicMock,
|
|
) -> None:
|
|
"""Test the disabled by default sensor entities."""
|
|
mock_config_entry.add_to_hass(hass)
|
|
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
|
|
|
state = hass.states.get("sensor.openevse_mock_config_ir_temperature")
|
|
assert state is None
|
|
|
|
entry = entity_registry.async_get("sensor.openevse_mock_config_ir_temperature")
|
|
assert entry
|
|
assert entry.disabled
|
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
|
|
|
state = hass.states.get("sensor.openevse_mock_config_temperature")
|
|
assert state is None
|
|
|
|
entry = entity_registry.async_get("sensor.openevse_mock_config_rtc_temperature")
|
|
assert entry
|
|
assert entry.disabled
|
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|