Refactor Teslemetry integration (#112480)

* Refactor Teslemetry

* Add abstractmethod

* Remove unused timestamp const

* Ruff

* Fix

* Update snapshots

* ruff

* Ruff

* ruff

* Lint

* Fix tests

* Fix tests and diag

* Refix snapshot

* Ruff

* Fix

* Fix bad merge

* has as property

* Remove _handle_coordinator_update

* Test and error changes
This commit is contained in:
Brett Adams 2024-05-10 18:52:33 +10:00 committed by GitHub
parent 11f5b48724
commit 1a4e416bf4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 562 additions and 323 deletions

View file

@ -8,10 +8,11 @@ from unittest.mock import patch
import pytest
from .const import (
COMMAND_OK,
LIVE_STATUS,
METADATA,
PRODUCTS,
RESPONSE_OK,
SITE_INFO,
VEHICLE_DATA,
WAKE_UP_ONLINE,
)
@ -70,7 +71,7 @@ def mock_request():
"""Mock Tesla Fleet API Vehicle Specific class."""
with patch(
"homeassistant.components.teslemetry.Teslemetry._request",
return_value=RESPONSE_OK,
return_value=COMMAND_OK,
) as mock_request:
yield mock_request
@ -83,3 +84,13 @@ def mock_live_status():
side_effect=lambda: deepcopy(LIVE_STATUS),
) as mock_live_status:
yield mock_live_status
@pytest.fixture(autouse=True)
def mock_site_info():
"""Mock Teslemetry Energy Specific site_info method."""
with patch(
"homeassistant.components.teslemetry.EnergySpecific.site_info",
side_effect=lambda: deepcopy(SITE_INFO),
) as mock_live_status:
yield mock_live_status