Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions tests/components/device_tracker/test_owntracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,31 @@
'_type': 'transition'}


REGION_ENTER_ZERO_MESSAGE = {
'lon': 1.0,
'event': 'enter',
'tid': 'user',
'desc': 'inner',
'wtst': 1,
't': 'b',
'acc': 0,
'tst': 2,
'lat': 2.0,
'_type': 'transition'}

REGION_LEAVE_ZERO_MESSAGE = {
'lon': 10.0,
'event': 'leave',
'tid': 'user',
'desc': 'inner',
'wtst': 1,
't': 'b',
'acc': 0,
'tst': 2,
'lat': 20.0,
'_type': 'transition'}


class TestDeviceTrackerOwnTracks(unittest.TestCase):
"""Test the OwnTrack sensor."""

Expand Down Expand Up @@ -293,6 +318,24 @@ def test_event_entry_exit_inaccurate(self):
# But does exit region correctly
self.assertFalse(owntracks.REGIONS_ENTERED[USER])

def test_event_entry_exit_zero_accuracy(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

farcy v1.1

  • D102: Missing docstring in public method

self.send_message(EVENT_TOPIC, REGION_ENTER_ZERO_MESSAGE)

# Enter uses the zone's gps co-ords
self.assert_location_latitude(2.1)
self.assert_location_accuracy(10.0)
self.assert_location_state('inner')

self.send_message(EVENT_TOPIC, REGION_LEAVE_ZERO_MESSAGE)

# Exit doesn't use zero gps
self.assert_location_latitude(2.1)
self.assert_location_accuracy(10.0)
self.assert_location_state('inner')

# But does exit region correctly
self.assertFalse(owntracks.REGIONS_ENTERED[USER])

def test_event_exit_outside_zone_sets_away(self):
"""Test the event for exit zone."""
self.send_message(EVENT_TOPIC, REGION_ENTER_MESSAGE)
Expand Down