Add tests to Nord Pool (#132468)

This commit is contained in:
G Johansson 2024-12-08 22:50:22 +01:00 committed by GitHub
parent 2f0e6a6dc7
commit a4ceed776e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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"