Skip to content

Commit

Permalink
Add Tile device tracker tests (#134137)
Browse files Browse the repository at this point in the history
  • Loading branch information
joostlek authored Dec 28, 2024
1 parent 4febe43 commit 4c5d0c2
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/components/tile/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
57 changes: 57 additions & 0 deletions tests/components/tile/snapshots/test_device_tracker.ambr
Original file line number Diff line number Diff line change
@@ -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',
})
# ---
27 changes: 27 additions & 0 deletions tests/components/tile/test_device_tracker.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4c5d0c2

Please sign in to comment.