mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Update for file header, docstrings, and PEP8/PEP257
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
"""
|
||||
tests.components.proximity
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
tests.components.test_proximity
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests proximity component.
|
||||
"""
|
||||
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.components import proximity
|
||||
|
||||
|
||||
class TestProximity:
|
||||
""" Test the Proximity component. """
|
||||
|
||||
@@ -25,7 +25,7 @@ class TestProximity:
|
||||
def teardown_method(self, method):
|
||||
""" Stop down stuff we started. """
|
||||
self.hass.stop()
|
||||
|
||||
|
||||
def test_proximity(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -45,12 +45,12 @@ class TestProximity:
|
||||
assert state.state == 'not set'
|
||||
assert state.attributes.get('nearest') == 'not set'
|
||||
assert state.attributes.get('dir_of_travel') == 'not set'
|
||||
|
||||
|
||||
self.hass.states.set('proximity.home', '0')
|
||||
self.hass.pool.block_till_done()
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.state == '0'
|
||||
|
||||
|
||||
def test_no_devices_in_config(self):
|
||||
assert not proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -61,7 +61,7 @@ class TestProximity:
|
||||
'tolerance': '1'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
def test_no_tolerance_in_config(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -75,7 +75,7 @@ class TestProximity:
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
def test_no_ignored_zones_in_config(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -87,7 +87,7 @@ class TestProximity:
|
||||
'tolerance': '1'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
def test_no_zone_in_config(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -100,8 +100,8 @@ class TestProximity:
|
||||
},
|
||||
'tolerance': '1'
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
def test_device_tracker_test1_in_zone(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -115,7 +115,7 @@ class TestProximity:
|
||||
'tolerance': '1'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'home',
|
||||
{
|
||||
@@ -128,7 +128,7 @@ class TestProximity:
|
||||
assert state.state == '0'
|
||||
assert state.attributes.get('nearest') == 'test1'
|
||||
assert state.attributes.get('dir_of_travel') == 'arrived'
|
||||
|
||||
|
||||
def test_device_trackers_in_zone(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -143,7 +143,7 @@ class TestProximity:
|
||||
'tolerance': '1'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'home',
|
||||
{
|
||||
@@ -164,7 +164,7 @@ class TestProximity:
|
||||
assert state.state == '0'
|
||||
assert (state.attributes.get('nearest') == 'test1, test2') or (state.attributes.get('nearest') == 'test2, test1')
|
||||
assert state.attributes.get('dir_of_travel') == 'arrived'
|
||||
|
||||
|
||||
def test_device_tracker_test1_away(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -178,7 +178,7 @@ class TestProximity:
|
||||
'tolerance': '1'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
{
|
||||
@@ -190,7 +190,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test1'
|
||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||
|
||||
|
||||
def test_device_tracker_test1_awayfurther(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -203,7 +203,7 @@ class TestProximity:
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
{
|
||||
@@ -226,7 +226,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test1'
|
||||
assert state.attributes.get('dir_of_travel') == 'away_from'
|
||||
|
||||
|
||||
def test_device_tracker_test1_awaycloser(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -239,7 +239,7 @@ class TestProximity:
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
{
|
||||
@@ -262,7 +262,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test1'
|
||||
assert state.attributes.get('dir_of_travel') == 'towards'
|
||||
|
||||
|
||||
def test_all_device_trackers_in_ignored_zone(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -275,7 +275,7 @@ class TestProximity:
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'work',
|
||||
{
|
||||
@@ -286,7 +286,7 @@ class TestProximity:
|
||||
assert state.state == 'not set'
|
||||
assert state.attributes.get('nearest') == 'not set'
|
||||
assert state.attributes.get('dir_of_travel') == 'not set'
|
||||
|
||||
|
||||
def test_device_tracker_test1_no_coordinates(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -300,7 +300,7 @@ class TestProximity:
|
||||
'tolerance': '1'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
{
|
||||
@@ -310,7 +310,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'not set'
|
||||
assert state.attributes.get('dir_of_travel') == 'not set'
|
||||
|
||||
|
||||
def test_device_tracker_test1_awayfurther_than_test2_first_test1(self):
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
@@ -336,7 +336,7 @@ class TestProximity:
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
{
|
||||
@@ -359,7 +359,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test1'
|
||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||
|
||||
|
||||
def test_device_tracker_test1_awayfurther_than_test2_first_test2(self):
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
@@ -385,7 +385,7 @@ class TestProximity:
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test2', 'not_home',
|
||||
{
|
||||
@@ -408,7 +408,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test1'
|
||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||
|
||||
|
||||
def test_device_tracker_test1_awayfurther_test2_in_ignored_zone(self):
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
@@ -434,7 +434,7 @@ class TestProximity:
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
{
|
||||
@@ -446,7 +446,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test1'
|
||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||
|
||||
|
||||
def test_device_tracker_test1_awayfurther_than_test2_first_test1_than_test2_than_test1(self):
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
@@ -472,7 +472,7 @@ class TestProximity:
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
{
|
||||
@@ -481,7 +481,7 @@ class TestProximity:
|
||||
'longitude': 5.1
|
||||
})
|
||||
self.hass.pool.block_till_done()
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test2', 'not_home',
|
||||
{
|
||||
@@ -515,7 +515,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test2'
|
||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||
|
||||
|
||||
def test_device_tracker_test1_awayfurther_a_bit(self):
|
||||
assert proximity.setup(self.hass, {
|
||||
'proximity': {
|
||||
@@ -529,7 +529,7 @@ class TestProximity:
|
||||
'tolerance': 1000
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
{
|
||||
@@ -552,7 +552,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test1'
|
||||
assert state.attributes.get('dir_of_travel') == 'stationary'
|
||||
|
||||
|
||||
def test_device_tracker_test1_nearest_after_test2_in_ignored_zone(self):
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
@@ -578,7 +578,7 @@ class TestProximity:
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test1', 'not_home',
|
||||
{
|
||||
@@ -590,7 +590,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test1'
|
||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test2', 'not_home',
|
||||
{
|
||||
@@ -602,7 +602,7 @@ class TestProximity:
|
||||
state = self.hass.states.get('proximity.home')
|
||||
assert state.attributes.get('nearest') == 'test2'
|
||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||
|
||||
|
||||
self.hass.states.set(
|
||||
'device_tracker.test2', 'work',
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user