Config entry device tracker (#24040)
* Move zone helpers to zone root * Add config entry support to device tracker * Convert Geofency * Convert GPSLogger * Track unsub per entry * Convert locative * Migrate OwnTracks * Lint * location -> latitude, longitude props * Lint * lint * Fix test
This commit is contained in:
1 parent
144b530045
commit
e6d7f6ed71
20 files changed
+946
-517
No files matched your search
@@ -165,7 +165,7 @@ async def test_enter_with_attrs(hass, gpslogger_client, webhook_id):
|
||||
data['device']))
|
||||
assert state.state == STATE_NOT_HOME
|
||||
assert state.attributes['gps_accuracy'] == 10.5
|
||||
assert state.attributes['battery'] == 10.0
|
||||
assert state.attributes['battery_level'] == 10.0
|
||||
assert state.attributes['speed'] == 100.0
|
||||
assert state.attributes['direction'] == 105.32
|
||||
assert state.attributes['altitude'] == 102.0
|
||||
|
||||
@@ -861,10 +861,9 @@ async def test_event_beacon_unknown_zone_no_location(hass, context):
|
||||
# the Device during test case setup.
|
||||
assert_location_state(hass, 'None')
|
||||
|
||||
# home is the state of a Device constructed through
|
||||
# the normal code path on it's first observation with
|
||||
# the conditions I pass along.
|
||||
assert_mobile_tracker_state(hass, 'home', 'unknown')
|
||||
# We have had no location yet, so the beacon status
|
||||
# set to unknown.
|
||||
assert_mobile_tracker_state(hass, 'unknown', 'unknown')
|
||||
|
||||
|
||||
async def test_event_beacon_unknown_zone(hass, context):
|
||||
@@ -1276,7 +1275,7 @@ async def test_single_waypoint_import(hass, context):
|
||||
async def test_not_implemented_message(hass, context):
|
||||
"""Handle not implemented message type."""
|
||||
patch_handler = patch('homeassistant.components.owntracks.'
|
||||
'device_tracker.async_handle_not_impl_msg',
|
||||
'messages.async_handle_not_impl_msg',
|
||||
return_value=mock_coro(False))
|
||||
patch_handler.start()
|
||||
assert not await send_message(hass, LWT_TOPIC, LWT_MESSAGE)
|
||||
@@ -1286,7 +1285,7 @@ async def test_not_implemented_message(hass, context):
|
||||
async def test_unsupported_message(hass, context):
|
||||
"""Handle not implemented message type."""
|
||||
patch_handler = patch('homeassistant.components.owntracks.'
|
||||
'device_tracker.async_handle_unsupported_msg',
|
||||
'messages.async_handle_unsupported_msg',
|
||||
return_value=mock_coro(False))
|
||||
patch_handler.start()
|
||||
assert not await send_message(hass, BAD_TOPIC, BAD_MESSAGE)
|
||||
@@ -1374,7 +1373,7 @@ def config_context(hass, setup_comp):
|
||||
patch_save.stop()
|
||||
|
||||
|
||||
@patch('homeassistant.components.owntracks.device_tracker.get_cipher',
|
||||
@patch('homeassistant.components.owntracks.messages.get_cipher',
|
||||
mock_cipher)
|
||||
async def test_encrypted_payload(hass, setup_comp):
|
||||
"""Test encrypted payload."""
|
||||
@@ -1385,7 +1384,7 @@ async def test_encrypted_payload(hass, setup_comp):
|
||||
assert_location_latitude(hass, LOCATION_MESSAGE['lat'])
|
||||
|
||||
|
||||
@patch('homeassistant.components.owntracks.device_tracker.get_cipher',
|
||||
@patch('homeassistant.components.owntracks.messages.get_cipher',
|
||||
mock_cipher)
|
||||
async def test_encrypted_payload_topic_key(hass, setup_comp):
|
||||
"""Test encrypted payload with a topic key."""
|
||||
@@ -1398,7 +1397,7 @@ async def test_encrypted_payload_topic_key(hass, setup_comp):
|
||||
assert_location_latitude(hass, LOCATION_MESSAGE['lat'])
|
||||
|
||||
|
||||
@patch('homeassistant.components.owntracks.device_tracker.get_cipher',
|
||||
@patch('homeassistant.components.owntracks.messages.get_cipher',
|
||||
mock_cipher)
|
||||
async def test_encrypted_payload_no_key(hass, setup_comp):
|
||||
"""Test encrypted payload with no key, ."""
|
||||
@@ -1411,7 +1410,7 @@ async def test_encrypted_payload_no_key(hass, setup_comp):
|
||||
assert hass.states.get(DEVICE_TRACKER_STATE) is None
|
||||
|
||||
|
||||
@patch('homeassistant.components.owntracks.device_tracker.get_cipher',
|
||||
@patch('homeassistant.components.owntracks.messages.get_cipher',
|
||||
mock_cipher)
|
||||
async def test_encrypted_payload_wrong_key(hass, setup_comp):
|
||||
"""Test encrypted payload with wrong key."""
|
||||
@@ -1422,7 +1421,7 @@ async def test_encrypted_payload_wrong_key(hass, setup_comp):
|
||||
assert hass.states.get(DEVICE_TRACKER_STATE) is None
|
||||
|
||||
|
||||
@patch('homeassistant.components.owntracks.device_tracker.get_cipher',
|
||||
@patch('homeassistant.components.owntracks.messages.get_cipher',
|
||||
mock_cipher)
|
||||
async def test_encrypted_payload_wrong_topic_key(hass, setup_comp):
|
||||
"""Test encrypted payload with wrong topic key."""
|
||||
@@ -1435,7 +1434,7 @@ async def test_encrypted_payload_wrong_topic_key(hass, setup_comp):
|
||||
assert hass.states.get(DEVICE_TRACKER_STATE) is None
|
||||
|
||||
|
||||
@patch('homeassistant.components.owntracks.device_tracker.get_cipher',
|
||||
@patch('homeassistant.components.owntracks.messages.get_cipher',
|
||||
mock_cipher)
|
||||
async def test_encrypted_payload_no_topic_key(hass, setup_comp):
|
||||
"""Test encrypted payload with no topic key."""
|
||||
|
||||
@@ -142,7 +142,7 @@ class TestComponentZone(unittest.TestCase):
|
||||
]
|
||||
})
|
||||
self.hass.block_till_done()
|
||||
active = zone.zone.active_zone(self.hass, 32.880600, -117.237561)
|
||||
active = zone.async_active_zone(self.hass, 32.880600, -117.237561)
|
||||
assert active is None
|
||||
|
||||
def test_active_zone_skips_passive_zones_2(self):
|
||||
@@ -158,7 +158,7 @@ class TestComponentZone(unittest.TestCase):
|
||||
]
|
||||
})
|
||||
self.hass.block_till_done()
|
||||
active = zone.zone.active_zone(self.hass, 32.880700, -117.237561)
|
||||
active = zone.async_active_zone(self.hass, 32.880700, -117.237561)
|
||||
assert 'zone.active_zone' == active.entity_id
|
||||
|
||||
def test_active_zone_prefers_smaller_zone_if_same_distance(self):
|
||||
@@ -182,7 +182,7 @@ class TestComponentZone(unittest.TestCase):
|
||||
]
|
||||
})
|
||||
|
||||
active = zone.zone.active_zone(self.hass, latitude, longitude)
|
||||
active = zone.async_active_zone(self.hass, latitude, longitude)
|
||||
assert 'zone.small_zone' == active.entity_id
|
||||
|
||||
def test_active_zone_prefers_smaller_zone_if_same_distance_2(self):
|
||||
@@ -200,7 +200,7 @@ class TestComponentZone(unittest.TestCase):
|
||||
]
|
||||
})
|
||||
|
||||
active = zone.zone.active_zone(self.hass, latitude, longitude)
|
||||
active = zone.async_active_zone(self.hass, latitude, longitude)
|
||||
assert 'zone.smallest_zone' == active.entity_id
|
||||
|
||||
def test_in_zone_works_for_passive_zones(self):
|
||||
|
||||
Reference in new issue
Block a user