Load/unload gpslogger entities correctly between component and platform (#20448)
* Embed device_tracker in gpslogger * Load/unload gpslogger entities correctly between component and platform * Await the coroutine directly
This commit is contained in:
1 parent
0c87fb421e
commit
d179686edf
4 files changed
+74
-39
No files matched your search
@@ -2,15 +2,17 @@
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
import pytest
|
||||
from homeassistant.helpers.dispatcher import DATA_DISPATCHER
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import zone
|
||||
from homeassistant.components import zone, gpslogger
|
||||
from homeassistant.components.device_tracker import \
|
||||
DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||
from homeassistant.components.gpslogger import DOMAIN
|
||||
from homeassistant.components.gpslogger import DOMAIN, TRACKER_UPDATE
|
||||
from homeassistant.const import HTTP_OK, HTTP_UNPROCESSABLE_ENTITY, \
|
||||
STATE_HOME, STATE_NOT_HOME
|
||||
STATE_HOME, STATE_NOT_HOME, CONF_WEBHOOK_ID
|
||||
from homeassistant.setup import async_setup_component
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
HOME_LATITUDE = 37.239622
|
||||
HOME_LONGITUDE = -115.815811
|
||||
@@ -164,3 +166,21 @@ async def test_enter_with_attrs(hass, gpslogger_client, webhook_id):
|
||||
assert 102.0 == state.attributes['altitude']
|
||||
assert 'gps' == state.attributes['provider']
|
||||
assert 'running' == state.attributes['activity']
|
||||
|
||||
|
||||
@pytest.mark.xfail(
|
||||
reason='The device_tracker component does not support unloading yet.'
|
||||
)
|
||||
async def test_load_unload_entry(hass):
|
||||
"""Test that the appropriate dispatch signals are added and removed."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data={
|
||||
CONF_WEBHOOK_ID: 'gpslogger_test'
|
||||
})
|
||||
|
||||
await gpslogger.async_setup_entry(hass, entry)
|
||||
await hass.async_block_till_done()
|
||||
assert 1 == len(hass.data[DATA_DISPATCHER][TRACKER_UPDATE])
|
||||
|
||||
await gpslogger.async_unload_entry(hass, entry)
|
||||
await hass.async_block_till_done()
|
||||
assert 0 == len(hass.data[DATA_DISPATCHER][TRACKER_UPDATE])
|
||||
Reference in new issue
Block a user