mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Clean up geofency test (#21397)
This commit is contained in:
parent
65bc7a6fbd
commit
7255fbdf3a
@ -10,11 +10,10 @@ from homeassistant.components.geofency import (
|
|||||||
CONF_MOBILE_BEACONS, DOMAIN, TRACKER_UPDATE)
|
CONF_MOBILE_BEACONS, DOMAIN, TRACKER_UPDATE)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
HTTP_OK, HTTP_UNPROCESSABLE_ENTITY, STATE_HOME,
|
HTTP_OK, HTTP_UNPROCESSABLE_ENTITY, STATE_HOME,
|
||||||
STATE_NOT_HOME, CONF_WEBHOOK_ID)
|
STATE_NOT_HOME)
|
||||||
from homeassistant.helpers.dispatcher import DATA_DISPATCHER
|
from homeassistant.helpers.dispatcher import DATA_DISPATCHER
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
from tests.common import MockConfigEntry
|
|
||||||
|
|
||||||
HOME_LATITUDE = 37.239622
|
HOME_LATITUDE = 37.239622
|
||||||
HOME_LONGITUDE = -115.815811
|
HOME_LONGITUDE = -115.815811
|
||||||
@ -288,16 +287,22 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
|
|||||||
@pytest.mark.xfail(
|
@pytest.mark.xfail(
|
||||||
reason='The device_tracker component does not support unloading yet.'
|
reason='The device_tracker component does not support unloading yet.'
|
||||||
)
|
)
|
||||||
async def test_load_unload_entry(hass, geofency_client):
|
async def test_load_unload_entry(hass, geofency_client, webhook_id):
|
||||||
"""Test that the appropriate dispatch signals are added and removed."""
|
"""Test that the appropriate dispatch signals are added and removed."""
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data={
|
url = '/api/webhook/{}'.format(webhook_id)
|
||||||
CONF_WEBHOOK_ID: 'geofency_test'
|
|
||||||
})
|
|
||||||
|
|
||||||
await geofency.async_setup_entry(hass, entry)
|
# Enter the Home zone
|
||||||
|
req = await geofency_client.post(url, data=GPS_ENTER_HOME)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert 1 == len(hass.data[DATA_DISPATCHER][TRACKER_UPDATE])
|
assert req.status == HTTP_OK
|
||||||
|
device_name = slugify(GPS_ENTER_HOME['device'])
|
||||||
|
state_name = hass.states.get('{}.{}'.format(
|
||||||
|
'device_tracker', device_name)).state
|
||||||
|
assert STATE_HOME == state_name
|
||||||
|
assert len(hass.data[DATA_DISPATCHER][TRACKER_UPDATE]) == 1
|
||||||
|
|
||||||
await geofency.async_unload_entry(hass, entry)
|
entry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||||
|
|
||||||
|
assert await geofency.async_unload_entry(hass, entry)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert 0 == len(hass.data[DATA_DISPATCHER][TRACKER_UPDATE])
|
assert not hass.data[DATA_DISPATCHER][TRACKER_UPDATE]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user