Add Tile device tracker tests (#134137)
parent
4febe43021
commit
4c5d0c2ec4
|
@ -22,6 +22,15 @@ def tile() -> AsyncMock:
|
|||
mock = AsyncMock(spec=Tile)
|
||||
mock.uuid = "19264d2dffdbca32"
|
||||
mock.name = "Wallet"
|
||||
mock.dead = False
|
||||
mock.latitude = 1
|
||||
mock.longitude = 1
|
||||
mock.altitude = 0
|
||||
mock.lost = False
|
||||
mock.last_timestamp = datetime(2020, 8, 12, 17, 55, 26)
|
||||
mock.lost_timestamp = datetime(1969, 12, 31, 19, 0, 0)
|
||||
mock.ring_state = "STOPPED"
|
||||
mock.voip_state = "OFFLINE"
|
||||
mock.as_dict.return_value = {
|
||||
"accuracy": 13.496111,
|
||||
"altitude": 0,
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
# serializer version: 1
|
||||
# name: test_all_entities[device_tracker.wallet-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'device_tracker',
|
||||
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||
'entity_id': 'device_tracker.wallet',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'tile',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'tile',
|
||||
'unique_id': 'user@host.com_19264d2dffdbca32',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[device_tracker.wallet-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'altitude': 0,
|
||||
'friendly_name': 'Wallet',
|
||||
'gps_accuracy': 1,
|
||||
'is_lost': False,
|
||||
'last_lost_timestamp': datetime.datetime(1970, 1, 1, 3, 0, tzinfo=datetime.timezone.utc),
|
||||
'last_timestamp': datetime.datetime(2020, 8, 13, 0, 55, 26, tzinfo=datetime.timezone.utc),
|
||||
'latitude': 1,
|
||||
'longitude': 1,
|
||||
'ring_state': 'STOPPED',
|
||||
'source_type': <SourceType.GPS: 'gps'>,
|
||||
'voip_state': 'OFFLINE',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'device_tracker.wallet',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'not_home',
|
||||
})
|
||||
# ---
|
|
@ -0,0 +1,27 @@
|
|||
"""Tests for the Tile Device tracker platform."""
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
async def test_all_entities(
|
||||
hass: HomeAssistant,
|
||||
snapshot: SnapshotAssertion,
|
||||
mock_pytile: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test all entities."""
|
||||
with patch("homeassistant.components.tile.PLATFORMS", [Platform.DEVICE_TRACKER]):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
Loading…
Reference in New Issue