mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Add tests to Nord Pool (#132468)
This commit is contained in:
parent
2f0e6a6dc7
commit
a4ceed776e
@ -6,6 +6,7 @@ import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
@ -23,3 +24,39 @@ async def test_sensor(
|
||||
"""Test the Nord Pool sensor."""
|
||||
|
||||
await snapshot_platform(hass, entity_registry, snapshot, load_int.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2024-11-05T23:00:00+00:00")
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_sensor_no_next_price(hass: HomeAssistant, load_int: ConfigEntry) -> None:
|
||||
"""Test the Nord Pool sensor."""
|
||||
|
||||
current_price = hass.states.get("sensor.nord_pool_se3_current_price")
|
||||
last_price = hass.states.get("sensor.nord_pool_se3_previous_price")
|
||||
next_price = hass.states.get("sensor.nord_pool_se3_next_price")
|
||||
|
||||
assert current_price is not None
|
||||
assert last_price is not None
|
||||
assert next_price is not None
|
||||
assert current_price.state == "0.28914"
|
||||
assert last_price.state == "0.28914"
|
||||
assert next_price.state == STATE_UNKNOWN
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2024-11-05T00:00:00+01:00")
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_sensor_no_previous_price(
|
||||
hass: HomeAssistant, load_int: ConfigEntry
|
||||
) -> None:
|
||||
"""Test the Nord Pool sensor."""
|
||||
|
||||
current_price = hass.states.get("sensor.nord_pool_se3_current_price")
|
||||
last_price = hass.states.get("sensor.nord_pool_se3_previous_price")
|
||||
next_price = hass.states.get("sensor.nord_pool_se3_next_price")
|
||||
|
||||
assert current_price is not None
|
||||
assert last_price is not None
|
||||
assert next_price is not None
|
||||
assert current_price.state == "0.25073"
|
||||
assert last_price.state == STATE_UNKNOWN
|
||||
assert next_price.state == "0.07636"
|
||||
|
Loading…
x
Reference in New Issue
Block a user