Improve coordinator logic in Tessie to allow sleep (#107988)

* Poll status before state

* Tests
This commit is contained in:
Brett Adams 2024-01-19 02:40:36 +10:00 committed by GitHub
parent cdb798bec0
commit 32b0bf6b4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 60 additions and 31 deletions

View file

@ -5,7 +5,11 @@ from unittest.mock import patch
import pytest
from .common import TEST_STATE_OF_ALL_VEHICLES, TEST_VEHICLE_STATE_ONLINE
from .common import (
TEST_STATE_OF_ALL_VEHICLES,
TEST_VEHICLE_STATE_ONLINE,
TEST_VEHICLE_STATUS_AWAKE,
)
@pytest.fixture
@ -18,6 +22,16 @@ def mock_get_state():
yield mock_get_state
@pytest.fixture
def mock_get_status():
"""Mock get_status function."""
with patch(
"homeassistant.components.tessie.coordinator.get_status",
return_value=TEST_VEHICLE_STATUS_AWAKE,
) as mock_get_status:
yield mock_get_status
@pytest.fixture
def mock_get_state_of_all_vehicles():
"""Mock get_state_of_all_vehicles function."""