mirror of
https://github.com/elisspace/core.git
synced 2026-09-29 13:59:54 +00:00
Add restore state to OwnTracks device tracker (#24256)
* Add restore state to OwnTracks device tracker * Lint * Also store entity devices * Update test_device_tracker.py
This commit is contained in:
committed by
Pascal Vizeli
parent
a8c73ffb93
commit
d2d3f27f85
@@ -1491,3 +1491,47 @@ async def test_region_mapping(hass, setup_comp):
|
||||
|
||||
await send_message(hass, EVENT_TOPIC, message)
|
||||
assert_location_state(hass, 'inner')
|
||||
|
||||
|
||||
async def test_restore_state(hass, hass_client):
|
||||
"""Test that we can restore state."""
|
||||
entry = MockConfigEntry(domain='owntracks', data={
|
||||
'webhook_id': 'owntracks_test',
|
||||
'secret': 'abcd',
|
||||
})
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
client = await hass_client()
|
||||
resp = await client.post(
|
||||
'/api/webhook/owntracks_test',
|
||||
json=LOCATION_MESSAGE,
|
||||
headers={
|
||||
'X-Limit-u': 'Paulus',
|
||||
'X-Limit-d': 'Pixel',
|
||||
}
|
||||
)
|
||||
assert resp.status == 200
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state_1 = hass.states.get('device_tracker.paulus_pixel')
|
||||
assert state_1 is not None
|
||||
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state_2 = hass.states.get('device_tracker.paulus_pixel')
|
||||
assert state_2 is not None
|
||||
|
||||
assert state_1 is not state_2
|
||||
|
||||
assert state_1.state == state_2.state
|
||||
assert state_1.name == state_2.name
|
||||
assert state_1.attributes['latitude'] == state_2.attributes['latitude']
|
||||
assert state_1.attributes['longitude'] == state_2.attributes['longitude']
|
||||
assert state_1.attributes['battery_level'] == \
|
||||
state_2.attributes['battery_level']
|
||||
assert state_1.attributes['source_type'] == \
|
||||
state_2.attributes['source_type']
|
||||
|
||||
Reference in New Issue
Block a user