mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Fix shared wakelock across Tesla Fleet vehicles (#181658)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""The Tesla Fleet integration models."""
|
||||
|
||||
import asyncio
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from tesla_fleet_api.const import Scope
|
||||
from tesla_fleet_api.tesla import EnergySite, VehicleFleet
|
||||
@@ -34,7 +34,7 @@ class TeslaFleetVehicleData:
|
||||
vin: str
|
||||
device: DeviceInfo
|
||||
signing: bool
|
||||
wakelock = asyncio.Lock()
|
||||
wakelock: asyncio.Lock = field(default_factory=asyncio.Lock)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Test the Tesla Fleet models."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.components.tesla_fleet.models import TeslaFleetVehicleData
|
||||
|
||||
|
||||
def test_wakelock_is_per_instance() -> None:
|
||||
"""Each vehicle must get its own wakelock, not a lock shared across the account."""
|
||||
kwargs = {
|
||||
"api": Mock(),
|
||||
"coordinator": Mock(),
|
||||
"vin": "VIN",
|
||||
"device": Mock(),
|
||||
"signing": False,
|
||||
}
|
||||
a = TeslaFleetVehicleData(**kwargs)
|
||||
b = TeslaFleetVehicleData(**kwargs)
|
||||
|
||||
assert a.wakelock is not b.wakelock
|
||||
Reference in New Issue
Block a user