Bump pytraccar to 1.0.0 (#75671)
This commit is contained in:
parent
ea354f3d5f
commit
e87c2b9e25
5 changed files with 128 additions and 103 deletions
|
@ -2,6 +2,8 @@
|
|||
from datetime import datetime
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from pytraccar import ReportsEventeModel
|
||||
|
||||
from homeassistant.components.device_tracker.const import DOMAIN
|
||||
from homeassistant.components.traccar.device_tracker import (
|
||||
PLATFORM_SCHEMA as TRACCAR_PLATFORM_SCHEMA,
|
||||
|
@ -35,26 +37,39 @@ async def test_import_events_catch_all(hass):
|
|||
device = {"id": 1, "name": "abc123"}
|
||||
api_mock = AsyncMock()
|
||||
api_mock.devices = [device]
|
||||
api_mock.get_events.return_value = [
|
||||
{
|
||||
"deviceId": device["id"],
|
||||
"type": "ignitionOn",
|
||||
"serverTime": datetime.utcnow(),
|
||||
"attributes": {},
|
||||
},
|
||||
{
|
||||
"deviceId": device["id"],
|
||||
"type": "ignitionOff",
|
||||
"serverTime": datetime.utcnow(),
|
||||
"attributes": {},
|
||||
},
|
||||
api_mock.get_reports_events.return_value = [
|
||||
ReportsEventeModel(
|
||||
**{
|
||||
"id": 1,
|
||||
"positionId": 1,
|
||||
"geofenceId": 1,
|
||||
"maintenanceId": 1,
|
||||
"deviceId": device["id"],
|
||||
"type": "ignitionOn",
|
||||
"eventTime": datetime.utcnow().isoformat(),
|
||||
"attributes": {},
|
||||
}
|
||||
),
|
||||
ReportsEventeModel(
|
||||
**{
|
||||
"id": 2,
|
||||
"positionId": 2,
|
||||
"geofenceId": 1,
|
||||
"maintenanceId": 1,
|
||||
"deviceId": device["id"],
|
||||
"type": "ignitionOff",
|
||||
"eventTime": datetime.utcnow().isoformat(),
|
||||
"attributes": {},
|
||||
}
|
||||
),
|
||||
]
|
||||
|
||||
events_ignition_on = async_capture_events(hass, "traccar_ignition_on")
|
||||
events_ignition_off = async_capture_events(hass, "traccar_ignition_off")
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.traccar.device_tracker.API", return_value=api_mock
|
||||
"homeassistant.components.traccar.device_tracker.ApiClient",
|
||||
return_value=api_mock,
|
||||
):
|
||||
assert await async_setup_component(hass, DOMAIN, conf_dict)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue