mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use snapshot assertion for EasyEnergy diagnostics test (#98909)
This commit is contained in:
parent
8d576c900d
commit
602a80c35c
63
tests/components/easyenergy/snapshots/test_diagnostics.ambr
Normal file
63
tests/components/easyenergy/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_diagnostics
|
||||||
|
dict({
|
||||||
|
'energy_return': dict({
|
||||||
|
'average_price': 0.14599,
|
||||||
|
'current_hour_price': 0.18629,
|
||||||
|
'highest_price_time': '2023-01-19T16:00:00+00:00',
|
||||||
|
'lowest_price_time': '2023-01-19T02:00:00+00:00',
|
||||||
|
'max_price': 0.20394,
|
||||||
|
'min_price': 0.10172,
|
||||||
|
'next_hour_price': 0.20394,
|
||||||
|
'percentage_of_max': 91.35,
|
||||||
|
}),
|
||||||
|
'energy_usage': dict({
|
||||||
|
'average_price': 0.17665,
|
||||||
|
'current_hour_price': 0.22541,
|
||||||
|
'highest_price_time': '2023-01-19T16:00:00+00:00',
|
||||||
|
'lowest_price_time': '2023-01-19T02:00:00+00:00',
|
||||||
|
'max_price': 0.24677,
|
||||||
|
'min_price': 0.12308,
|
||||||
|
'next_hour_price': 0.24677,
|
||||||
|
'percentage_of_max': 91.34,
|
||||||
|
}),
|
||||||
|
'entry': dict({
|
||||||
|
'title': 'energy',
|
||||||
|
}),
|
||||||
|
'gas': dict({
|
||||||
|
'current_hour_price': 0.7253,
|
||||||
|
'next_hour_price': 0.7253,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_diagnostics_no_gas_today
|
||||||
|
dict({
|
||||||
|
'energy_return': dict({
|
||||||
|
'average_price': 0.14599,
|
||||||
|
'current_hour_price': 0.18629,
|
||||||
|
'highest_price_time': '2023-01-19T16:00:00+00:00',
|
||||||
|
'lowest_price_time': '2023-01-19T02:00:00+00:00',
|
||||||
|
'max_price': 0.20394,
|
||||||
|
'min_price': 0.10172,
|
||||||
|
'next_hour_price': 0.20394,
|
||||||
|
'percentage_of_max': 91.35,
|
||||||
|
}),
|
||||||
|
'energy_usage': dict({
|
||||||
|
'average_price': 0.17665,
|
||||||
|
'current_hour_price': 0.22541,
|
||||||
|
'highest_price_time': '2023-01-19T16:00:00+00:00',
|
||||||
|
'lowest_price_time': '2023-01-19T02:00:00+00:00',
|
||||||
|
'max_price': 0.24677,
|
||||||
|
'min_price': 0.12308,
|
||||||
|
'next_hour_price': 0.24677,
|
||||||
|
'percentage_of_max': 91.34,
|
||||||
|
}),
|
||||||
|
'entry': dict({
|
||||||
|
'title': 'energy',
|
||||||
|
}),
|
||||||
|
'gas': dict({
|
||||||
|
'current_hour_price': None,
|
||||||
|
'next_hour_price': None,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
# ---
|
@ -3,6 +3,7 @@ from unittest.mock import MagicMock
|
|||||||
|
|
||||||
from easyenergy import EasyEnergyNoDataError
|
from easyenergy import EasyEnergyNoDataError
|
||||||
import pytest
|
import pytest
|
||||||
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.homeassistant import SERVICE_UPDATE_ENTITY
|
from homeassistant.components.homeassistant import SERVICE_UPDATE_ENTITY
|
||||||
from homeassistant.const import ATTR_ENTITY_ID
|
from homeassistant.const import ATTR_ENTITY_ID
|
||||||
@ -19,39 +20,13 @@ async def test_diagnostics(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
init_integration: MockConfigEntry,
|
init_integration: MockConfigEntry,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test diagnostics."""
|
"""Test diagnostics."""
|
||||||
assert await get_diagnostics_for_config_entry(
|
assert (
|
||||||
hass, hass_client, init_integration
|
await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
||||||
) == {
|
== snapshot
|
||||||
"entry": {
|
)
|
||||||
"title": "energy",
|
|
||||||
},
|
|
||||||
"energy_usage": {
|
|
||||||
"current_hour_price": 0.22541,
|
|
||||||
"next_hour_price": 0.24677,
|
|
||||||
"average_price": 0.17665,
|
|
||||||
"max_price": 0.24677,
|
|
||||||
"min_price": 0.12308,
|
|
||||||
"highest_price_time": "2023-01-19T16:00:00+00:00",
|
|
||||||
"lowest_price_time": "2023-01-19T02:00:00+00:00",
|
|
||||||
"percentage_of_max": 91.34,
|
|
||||||
},
|
|
||||||
"energy_return": {
|
|
||||||
"current_hour_price": 0.18629,
|
|
||||||
"next_hour_price": 0.20394,
|
|
||||||
"average_price": 0.14599,
|
|
||||||
"max_price": 0.20394,
|
|
||||||
"min_price": 0.10172,
|
|
||||||
"highest_price_time": "2023-01-19T16:00:00+00:00",
|
|
||||||
"lowest_price_time": "2023-01-19T02:00:00+00:00",
|
|
||||||
"percentage_of_max": 91.35,
|
|
||||||
},
|
|
||||||
"gas": {
|
|
||||||
"current_hour_price": 0.7253,
|
|
||||||
"next_hour_price": 0.7253,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.freeze_time("2023-01-19 15:00:00")
|
@pytest.mark.freeze_time("2023-01-19 15:00:00")
|
||||||
@ -60,6 +35,7 @@ async def test_diagnostics_no_gas_today(
|
|||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_easyenergy: MagicMock,
|
mock_easyenergy: MagicMock,
|
||||||
init_integration: MockConfigEntry,
|
init_integration: MockConfigEntry,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test diagnostics, no gas sensors available."""
|
"""Test diagnostics, no gas sensors available."""
|
||||||
await async_setup_component(hass, "homeassistant", {})
|
await async_setup_component(hass, "homeassistant", {})
|
||||||
@ -73,34 +49,7 @@ async def test_diagnostics_no_gas_today(
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert await get_diagnostics_for_config_entry(
|
assert (
|
||||||
hass, hass_client, init_integration
|
await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
||||||
) == {
|
== snapshot
|
||||||
"entry": {
|
)
|
||||||
"title": "energy",
|
|
||||||
},
|
|
||||||
"energy_usage": {
|
|
||||||
"current_hour_price": 0.22541,
|
|
||||||
"next_hour_price": 0.24677,
|
|
||||||
"average_price": 0.17665,
|
|
||||||
"max_price": 0.24677,
|
|
||||||
"min_price": 0.12308,
|
|
||||||
"highest_price_time": "2023-01-19T16:00:00+00:00",
|
|
||||||
"lowest_price_time": "2023-01-19T02:00:00+00:00",
|
|
||||||
"percentage_of_max": 91.34,
|
|
||||||
},
|
|
||||||
"energy_return": {
|
|
||||||
"current_hour_price": 0.18629,
|
|
||||||
"next_hour_price": 0.20394,
|
|
||||||
"average_price": 0.14599,
|
|
||||||
"max_price": 0.20394,
|
|
||||||
"min_price": 0.10172,
|
|
||||||
"highest_price_time": "2023-01-19T16:00:00+00:00",
|
|
||||||
"lowest_price_time": "2023-01-19T02:00:00+00:00",
|
|
||||||
"percentage_of_max": 91.35,
|
|
||||||
},
|
|
||||||
"gas": {
|
|
||||||
"current_hour_price": None,
|
|
||||||
"next_hour_price": None,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user