mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Improve renault tests (#125064)
This commit is contained in:
parent
fa14321aa1
commit
72d5146a3e
460
tests/components/renault/snapshots/test_services.ambr
Normal file
460
tests/components/renault/snapshots/test_services.ambr
Normal file
@ -0,0 +1,460 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_service_set_charge_schedule[zoe_40]
|
||||||
|
list([
|
||||||
|
dict({
|
||||||
|
'activated': True,
|
||||||
|
'friday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'id': 1,
|
||||||
|
'monday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': True,
|
||||||
|
'friday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'id': 1,
|
||||||
|
'monday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'saturday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'sunday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'thursday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'tuesday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'wednesday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'saturday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'sunday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'thursday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'tuesday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'wednesday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
dict({
|
||||||
|
'activated': True,
|
||||||
|
'friday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'id': 2,
|
||||||
|
'monday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': True,
|
||||||
|
'friday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'id': 2,
|
||||||
|
'monday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'saturday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'sunday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'thursday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'tuesday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'wednesday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'saturday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'sunday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'thursday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'tuesday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'wednesday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
dict({
|
||||||
|
'activated': False,
|
||||||
|
'friday': None,
|
||||||
|
'id': 3,
|
||||||
|
'monday': None,
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': False,
|
||||||
|
'id': 3,
|
||||||
|
}),
|
||||||
|
'saturday': None,
|
||||||
|
'sunday': None,
|
||||||
|
'thursday': None,
|
||||||
|
'tuesday': None,
|
||||||
|
'wednesday': None,
|
||||||
|
}),
|
||||||
|
dict({
|
||||||
|
'activated': False,
|
||||||
|
'friday': None,
|
||||||
|
'id': 4,
|
||||||
|
'monday': None,
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': False,
|
||||||
|
'id': 4,
|
||||||
|
}),
|
||||||
|
'saturday': None,
|
||||||
|
'sunday': None,
|
||||||
|
'thursday': None,
|
||||||
|
'tuesday': None,
|
||||||
|
'wednesday': None,
|
||||||
|
}),
|
||||||
|
dict({
|
||||||
|
'activated': False,
|
||||||
|
'friday': None,
|
||||||
|
'id': 5,
|
||||||
|
'monday': None,
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': False,
|
||||||
|
'id': 5,
|
||||||
|
}),
|
||||||
|
'saturday': None,
|
||||||
|
'sunday': None,
|
||||||
|
'thursday': None,
|
||||||
|
'tuesday': None,
|
||||||
|
'wednesday': None,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
# ---
|
||||||
|
# name: test_service_set_charge_schedule_multi[zoe_40]
|
||||||
|
list([
|
||||||
|
dict({
|
||||||
|
'activated': True,
|
||||||
|
'friday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'id': 1,
|
||||||
|
'monday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': True,
|
||||||
|
'friday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'id': 1,
|
||||||
|
'monday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'saturday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'sunday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'thursday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'tuesday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'wednesday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'saturday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'sunday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'thursday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'tuesday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'wednesday': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 450,
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T00:00Z',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
dict({
|
||||||
|
'activated': True,
|
||||||
|
'friday': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'id': 2,
|
||||||
|
'monday': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': True,
|
||||||
|
'friday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'id': 2,
|
||||||
|
'monday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'saturday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'sunday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'thursday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'tuesday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'wednesday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'saturday': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'sunday': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'thursday': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 15,
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T23:30Z',
|
||||||
|
}),
|
||||||
|
'tuesday': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'raw_data': dict({
|
||||||
|
'duration': 30,
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'startTime': 'T12:00Z',
|
||||||
|
}),
|
||||||
|
'wednesday': None,
|
||||||
|
}),
|
||||||
|
dict({
|
||||||
|
'activated': False,
|
||||||
|
'friday': None,
|
||||||
|
'id': 3,
|
||||||
|
'monday': None,
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': False,
|
||||||
|
'id': 3,
|
||||||
|
}),
|
||||||
|
'saturday': None,
|
||||||
|
'sunday': None,
|
||||||
|
'thursday': None,
|
||||||
|
'tuesday': None,
|
||||||
|
'wednesday': None,
|
||||||
|
}),
|
||||||
|
dict({
|
||||||
|
'activated': False,
|
||||||
|
'friday': None,
|
||||||
|
'id': 4,
|
||||||
|
'monday': None,
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': False,
|
||||||
|
'id': 4,
|
||||||
|
}),
|
||||||
|
'saturday': None,
|
||||||
|
'sunday': None,
|
||||||
|
'thursday': None,
|
||||||
|
'tuesday': None,
|
||||||
|
'wednesday': None,
|
||||||
|
}),
|
||||||
|
dict({
|
||||||
|
'activated': False,
|
||||||
|
'friday': None,
|
||||||
|
'id': 5,
|
||||||
|
'monday': None,
|
||||||
|
'raw_data': dict({
|
||||||
|
'activated': False,
|
||||||
|
'id': 5,
|
||||||
|
}),
|
||||||
|
'saturday': None,
|
||||||
|
'sunday': None,
|
||||||
|
'thursday': None,
|
||||||
|
'tuesday': None,
|
||||||
|
'wednesday': None,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
# ---
|
@ -8,6 +8,7 @@ import pytest
|
|||||||
from renault_api.exceptions import RenaultException
|
from renault_api.exceptions import RenaultException
|
||||||
from renault_api.kamereon import schemas
|
from renault_api.kamereon import schemas
|
||||||
from renault_api.kamereon.models import ChargeSchedule
|
from renault_api.kamereon.models import ChargeSchedule
|
||||||
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.renault.const import DOMAIN
|
from homeassistant.components.renault.const import DOMAIN
|
||||||
from homeassistant.components.renault.services import (
|
from homeassistant.components.renault.services import (
|
||||||
@ -143,7 +144,7 @@ async def test_service_set_ac_start_with_date(
|
|||||||
|
|
||||||
|
|
||||||
async def test_service_set_charge_schedule(
|
async def test_service_set_charge_schedule(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
hass: HomeAssistant, config_entry: ConfigEntry, snapshot: SnapshotAssertion
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that service invokes renault_api with correct data."""
|
"""Test that service invokes renault_api with correct data."""
|
||||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
@ -176,11 +177,11 @@ async def test_service_set_charge_schedule(
|
|||||||
)
|
)
|
||||||
assert len(mock_action.mock_calls) == 1
|
assert len(mock_action.mock_calls) == 1
|
||||||
mock_call_data: list[ChargeSchedule] = mock_action.mock_calls[0][1][0]
|
mock_call_data: list[ChargeSchedule] = mock_action.mock_calls[0][1][0]
|
||||||
assert mock_action.mock_calls[0][1] == (mock_call_data,)
|
assert mock_call_data == snapshot
|
||||||
|
|
||||||
|
|
||||||
async def test_service_set_charge_schedule_multi(
|
async def test_service_set_charge_schedule_multi(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
hass: HomeAssistant, config_entry: ConfigEntry, snapshot: SnapshotAssertion
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that service invokes renault_api with correct data."""
|
"""Test that service invokes renault_api with correct data."""
|
||||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
@ -225,7 +226,7 @@ async def test_service_set_charge_schedule_multi(
|
|||||||
)
|
)
|
||||||
assert len(mock_action.mock_calls) == 1
|
assert len(mock_action.mock_calls) == 1
|
||||||
mock_call_data: list[ChargeSchedule] = mock_action.mock_calls[0][1][0]
|
mock_call_data: list[ChargeSchedule] = mock_action.mock_calls[0][1][0]
|
||||||
assert mock_action.mock_calls[0][1] == (mock_call_data,)
|
assert mock_call_data == snapshot
|
||||||
|
|
||||||
# Monday updated with new values
|
# Monday updated with new values
|
||||||
assert mock_call_data[1].monday.startTime == "T12:00Z"
|
assert mock_call_data[1].monday.startTime == "T12:00Z"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user