Update for file header, docstrings, and PEP8/PEP257
This commit is contained in:
parent
34b91cf6ce
commit
00afaac54c
74 changed files with 212 additions and 211 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
"""
|
||||||
|
tests.__init__
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Tests initialization.
|
||||||
|
"""
|
||||||
import betamax
|
import betamax
|
||||||
|
|
||||||
from homeassistant.util import location
|
from homeassistant.util import location
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.helper
|
tests.common
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
Helper method for writing tests.
|
Helper method for writing tests.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""
|
"""
|
||||||
tests.components.automation.test_init
|
tests.components.automation.test_init
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests automation component.
|
Tests automation component.
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
|
@ -267,7 +267,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
# 9 is below 10
|
# 9 is below 10
|
||||||
self.hass.states.set('test.entity', 9, { 'test_attribute': 11 })
|
self.hass.states.set('test.entity', 9, {'test_attribute': 11})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(1, len(self.calls))
|
self.assertEqual(1, len(self.calls))
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
# 11 is not below 10
|
# 11 is not below 10
|
||||||
self.hass.states.set('test.entity', 11, { 'test_attribute': 9 })
|
self.hass.states.set('test.entity', 11, {'test_attribute': 9})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(0, len(self.calls))
|
self.assertEqual(0, len(self.calls))
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
# 9 is below 10
|
# 9 is below 10
|
||||||
self.hass.states.set('test.entity', 'entity', { 'test_attribute': 9 })
|
self.hass.states.set('test.entity', 'entity', {'test_attribute': 9})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(1, len(self.calls))
|
self.assertEqual(1, len(self.calls))
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
# 11 is not below 10
|
# 11 is not below 10
|
||||||
self.hass.states.set('test.entity', 'entity', { 'test_attribute': 11 })
|
self.hass.states.set('test.entity', 'entity', {'test_attribute': 11})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(0, len(self.calls))
|
self.assertEqual(0, len(self.calls))
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
# 11 is not below 10, entity state value should not be tested
|
# 11 is not below 10, entity state value should not be tested
|
||||||
self.hass.states.set('test.entity', '9', { 'test_attribute': 11 })
|
self.hass.states.set('test.entity', '9', {'test_attribute': 11})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(0, len(self.calls))
|
self.assertEqual(0, len(self.calls))
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
# 9 is not below 10
|
# 9 is not below 10
|
||||||
self.hass.states.set('test.entity', 'entity', { 'test_attribute': 9, 'not_test_attribute': 11 })
|
self.hass.states.set('test.entity', 'entity', {'test_attribute': 9, 'not_test_attribute': 11})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(1, len(self.calls))
|
self.assertEqual(1, len(self.calls))
|
||||||
|
|
||||||
|
@ -399,7 +399,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
# 3 is below 10
|
# 3 is below 10
|
||||||
self.hass.states.set('test.entity', 'entity', { 'test_attribute': [11, 15, 3] })
|
self.hass.states.set('test.entity', 'entity', {'test_attribute': [11, 15, 3]})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(1, len(self.calls))
|
self.assertEqual(1, len(self.calls))
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
# 9 is below 10
|
# 9 is below 10
|
||||||
self.hass.states.set('test.entity', 'entity', { 'test_attribute': '0.9' })
|
self.hass.states.set('test.entity', 'entity', {'test_attribute': '0.9'})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(1, len(self.calls))
|
self.assertEqual(1, len(self.calls))
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
# 11 is not below 10
|
# 11 is not below 10
|
||||||
self.hass.states.set('test.entity', 'entity', { 'test_attribute': 11, 'not_test_attribute': 9 })
|
self.hass.states.set('test.entity', 'entity', {'test_attribute': 11, 'not_test_attribute': 9})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
self.assertEqual(0, len(self.calls))
|
self.assertEqual(0, len(self.calls))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.automation.test_state
|
tests.components.automation.test_state
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests state automation.
|
Tests state automation.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.automation.test_template
|
tests.components.automation.test_template
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests template automation.
|
Tests template automation.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.automation.test_location
|
tests.components.automation.test_zone
|
||||||
±±±~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests location automation.
|
Tests location automation.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
"""
|
"""
|
||||||
tests.components.binary_sensor.command_sensor
|
tests.components.binary_sensor.command_sensor
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests command binary sensor.
|
Tests command binary sensor.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_device_tracker
|
tests.components.device_tracker.test_init
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests the device tracker compoments.
|
Tests the device tracker compoments.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
"""
|
"""
|
||||||
tests.components.device_tracker.locative
|
tests.components.device_tracker.test_locative
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests the locative device tracker component.
|
Tests the locative device tracker component.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
@ -24,7 +23,8 @@ hass = None
|
||||||
|
|
||||||
def _url(data={}):
|
def _url(data={}):
|
||||||
""" Helper method to generate urls. """
|
""" Helper method to generate urls. """
|
||||||
data = "&".join(["{}={}".format(name, value) for name, value in data.items()])
|
data = "&".join(["{}={}".format(name, value) for
|
||||||
|
name, value in data.items()])
|
||||||
return "{}{}locative?{}".format(HTTP_BASE_URL, const.URL_API, data)
|
return "{}{}locative?{}".format(HTTP_BASE_URL, const.URL_API, data)
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ def tearDownModule(): # pylint: disable=invalid-name
|
||||||
""" Stops the Home Assistant server. """
|
""" Stops the Home Assistant server. """
|
||||||
hass.stop()
|
hass.stop()
|
||||||
|
|
||||||
|
|
||||||
# Stub out update_config or else Travis CI raises an exception
|
# Stub out update_config or else Travis CI raises an exception
|
||||||
@patch('homeassistant.components.device_tracker.update_config')
|
@patch('homeassistant.components.device_tracker.update_config')
|
||||||
class TestLocative(unittest.TestCase):
|
class TestLocative(unittest.TestCase):
|
||||||
|
@ -114,7 +115,6 @@ class TestLocative(unittest.TestCase):
|
||||||
req = requests.get(_url(copy))
|
req = requests.get(_url(copy))
|
||||||
self.assertEqual(422, req.status_code)
|
self.assertEqual(422, req.status_code)
|
||||||
|
|
||||||
|
|
||||||
def test_enter_and_exit(self, update_config):
|
def test_enter_and_exit(self, update_config):
|
||||||
""" Test when there is a known zone """
|
""" Test when there is a known zone """
|
||||||
data = {
|
data = {
|
||||||
|
@ -166,7 +166,6 @@ class TestLocative(unittest.TestCase):
|
||||||
state_name = hass.states.get('{}.{}'.format('device_tracker', data['device'])).state
|
state_name = hass.states.get('{}.{}'.format('device_tracker', data['device'])).state
|
||||||
self.assertEqual(state_name, 'work')
|
self.assertEqual(state_name, 'work')
|
||||||
|
|
||||||
|
|
||||||
def test_exit_after_enter(self, update_config):
|
def test_exit_after_enter(self, update_config):
|
||||||
""" Test when an exit message comes after an enter message """
|
""" Test when an exit message comes after an enter message """
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
"""
|
||||||
|
tests.components.device_tracker.test_mqtt
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Tests the MQTT device tracker component.
|
||||||
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""
|
"""
|
||||||
tests.components.sensor.template
|
tests.components.device_tracker.test_owntracks
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests template sensor.
|
Tests Owntracks device tracker.
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -111,14 +111,14 @@ class TestDeviceTrackerOwnTracks(unittest.TestCase):
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'zone.passive', 'zoning',
|
'zone.passive', 'zoning',
|
||||||
{
|
{
|
||||||
'name': 'zone',
|
'name': 'zone',
|
||||||
'latitude': 3.0,
|
'latitude': 3.0,
|
||||||
'longitude': 1.0,
|
'longitude': 1.0,
|
||||||
'radius': 10,
|
'radius': 10,
|
||||||
'passive': True
|
'passive': True
|
||||||
})
|
})
|
||||||
# Clear state between teste
|
# Clear state between teste
|
||||||
self.hass.states.set(DEVICE_TRACKER_STATE, None)
|
self.hass.states.set(DEVICE_TRACKER_STATE, None)
|
||||||
owntracks.REGIONS_ENTERED = defaultdict(list)
|
owntracks.REGIONS_ENTERED = defaultdict(list)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.garage_door.test_demo
|
tests.components.garage_door.test_demo
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests demo garage door component.
|
Tests demo garage door component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_switch
|
tests.components.test_init
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests switch component.
|
Tests light component.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-many-public-methods,protected-access
|
# pylint: disable=too-many-public-methods,protected-access
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -18,7 +18,7 @@ from tests.common import mock_service, get_test_home_assistant
|
||||||
|
|
||||||
|
|
||||||
class TestLight(unittest.TestCase):
|
class TestLight(unittest.TestCase):
|
||||||
""" Test the switch module. """
|
""" Test the light module. """
|
||||||
|
|
||||||
def setUp(self): # pylint: disable=invalid-name
|
def setUp(self): # pylint: disable=invalid-name
|
||||||
self.hass = get_test_home_assistant()
|
self.hass = get_test_home_assistant()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.light.test_mqtt
|
tests.components.light.test_mqtt
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests mqtt light.
|
Tests mqtt light.
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,9 @@ Tests demo media_player component.
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from pprint import pprint
|
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
from homeassistant.const import (
|
|
||||||
STATE_OFF, STATE_ON, STATE_UNKNOWN, STATE_PLAYING, STATE_PAUSED)
|
|
||||||
import homeassistant.components.media_player as mp
|
import homeassistant.components.media_player as mp
|
||||||
|
|
||||||
|
|
||||||
entity_id = 'media_player.walkman'
|
entity_id = 'media_player.walkman'
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,4 +134,3 @@ class TestDemoMediaPlayer(unittest.TestCase):
|
||||||
mp.media_seek(self.hass, 100, ent_id)
|
mp.media_seek(self.hass, 100, ent_id)
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
assert mock_seek.called
|
assert mock_seek.called
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
"""
|
"""
|
||||||
tests.components.notify.test_demo
|
tests.components.notify.test_demo
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Tests notify demo component
|
|
||||||
|
Tests notify demo component.
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.rollershutter.test_mqtt
|
tests.components.rollershutter.test_mqtt
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests MQTT rollershutter.
|
Tests MQTT rollershutter.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
"""
|
"""
|
||||||
tests.components.sensor.command_sensor
|
tests.components.sensor.test_command_sensor
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests command sensor.
|
Tests command sensor.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
|
@ -12,7 +11,7 @@ from homeassistant.components.sensor import command_sensor
|
||||||
|
|
||||||
|
|
||||||
class TestCommandSensorSensor(unittest.TestCase):
|
class TestCommandSensorSensor(unittest.TestCase):
|
||||||
""" Test the Template sensor. """
|
""" Test the Command line sensor. """
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.hass = ha.HomeAssistant()
|
self.hass = ha.HomeAssistant()
|
||||||
|
@ -22,7 +21,7 @@ class TestCommandSensorSensor(unittest.TestCase):
|
||||||
self.hass.stop()
|
self.hass.stop()
|
||||||
|
|
||||||
def test_setup(self):
|
def test_setup(self):
|
||||||
""" Test sensor setup """
|
""" Test sensor setup. """
|
||||||
config = {'name': 'Test',
|
config = {'name': 'Test',
|
||||||
'unit_of_measurement': 'in',
|
'unit_of_measurement': 'in',
|
||||||
'command': 'echo 5'}
|
'command': 'echo 5'}
|
||||||
|
@ -43,7 +42,7 @@ class TestCommandSensorSensor(unittest.TestCase):
|
||||||
self.assertEqual('5', entity.state)
|
self.assertEqual('5', entity.state)
|
||||||
|
|
||||||
def test_setup_bad_config(self):
|
def test_setup_bad_config(self):
|
||||||
""" Test setup with a bad config """
|
""" Test setup with a bad configuration. """
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
devices = []
|
devices = []
|
||||||
|
@ -59,7 +58,7 @@ class TestCommandSensorSensor(unittest.TestCase):
|
||||||
self.assertEqual(0, len(devices))
|
self.assertEqual(0, len(devices))
|
||||||
|
|
||||||
def test_template(self):
|
def test_template(self):
|
||||||
""" Test command sensor with template """
|
""" Test command sensor with template. """
|
||||||
data = command_sensor.CommandSensorData('echo 50')
|
data = command_sensor.CommandSensorData('echo 50')
|
||||||
|
|
||||||
entity = command_sensor.CommandSensor(
|
entity = command_sensor.CommandSensor(
|
||||||
|
@ -68,7 +67,7 @@ class TestCommandSensorSensor(unittest.TestCase):
|
||||||
self.assertEqual(5, float(entity.state))
|
self.assertEqual(5, float(entity.state))
|
||||||
|
|
||||||
def test_bad_command(self):
|
def test_bad_command(self):
|
||||||
""" Test bad command """
|
""" Test bad command. """
|
||||||
data = command_sensor.CommandSensorData('asdfasdf')
|
data = command_sensor.CommandSensorData('asdfasdf')
|
||||||
data.update()
|
data.update()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.sensor.test_mfi
|
tests.components.sensor.test_mfi
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests mFi sensor.
|
Tests mFi sensor.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
tests.components.sensor.test_mqtt
|
tests.components.sensor.test_mqtt
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests mqtt sensor.
|
Tests MQTT sensor.
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
"""
|
"""
|
||||||
tests.components.sensor.template
|
tests.components.sensor.test_template
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests template sensor.
|
Tests template sensor.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
import homeassistant.components.sensor as sensor
|
import homeassistant.components.sensor as sensor
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.sensor.test_yr
|
tests.components.sensor.test_yr
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Yr sensor.
|
Tests Yr sensor.
|
||||||
"""
|
"""
|
||||||
|
@ -73,7 +73,7 @@ class TestSensorYr:
|
||||||
assert '1025.1' == state.state
|
assert '1025.1' == state.state
|
||||||
|
|
||||||
state = self.hass.states.get('sensor.yr_wind_direction')
|
state = self.hass.states.get('sensor.yr_wind_direction')
|
||||||
assert '°'== state.attributes.get('unit_of_measurement')
|
assert '°' == state.attributes.get('unit_of_measurement')
|
||||||
assert '81.8' == state.state
|
assert '81.8' == state.state
|
||||||
|
|
||||||
state = self.hass.states.get('sensor.yr_humidity')
|
state = self.hass.states.get('sensor.yr_humidity')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.switch.test_command_switch
|
tests.components.switch.test_command_switch
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests command switch.
|
Tests command switch.
|
||||||
"""
|
"""
|
||||||
|
@ -55,7 +55,6 @@ class TestCommandSwitch(unittest.TestCase):
|
||||||
state = self.hass.states.get('switch.test')
|
state = self.hass.states.get('switch.test')
|
||||||
self.assertEqual(STATE_OFF, state.state)
|
self.assertEqual(STATE_OFF, state.state)
|
||||||
|
|
||||||
|
|
||||||
def test_state_value(self):
|
def test_state_value(self):
|
||||||
with tempfile.TemporaryDirectory() as tempdirname:
|
with tempfile.TemporaryDirectory() as tempdirname:
|
||||||
path = os.path.join(tempdirname, 'switch_status')
|
path = os.path.join(tempdirname, 'switch_status')
|
||||||
|
@ -79,7 +78,7 @@ class TestCommandSwitch(unittest.TestCase):
|
||||||
|
|
||||||
switch.turn_on(self.hass, 'switch.test')
|
switch.turn_on(self.hass, 'switch.test')
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
|
|
||||||
state = self.hass.states.get('switch.test')
|
state = self.hass.states.get('switch.test')
|
||||||
self.assertEqual(STATE_ON, state.state)
|
self.assertEqual(STATE_ON, state.state)
|
||||||
|
|
||||||
|
@ -89,7 +88,6 @@ class TestCommandSwitch(unittest.TestCase):
|
||||||
state = self.hass.states.get('switch.test')
|
state = self.hass.states.get('switch.test')
|
||||||
self.assertEqual(STATE_OFF, state.state)
|
self.assertEqual(STATE_OFF, state.state)
|
||||||
|
|
||||||
|
|
||||||
def test_state_json_value(self):
|
def test_state_json_value(self):
|
||||||
with tempfile.TemporaryDirectory() as tempdirname:
|
with tempfile.TemporaryDirectory() as tempdirname:
|
||||||
path = os.path.join(tempdirname, 'switch_status')
|
path = os.path.join(tempdirname, 'switch_status')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_switch
|
tests.components.switch.test_init
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests switch component.
|
Tests switch component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.switch.test_mfi
|
tests.components.switch.test_mfi
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests mFi switch.
|
Tests mFi switch.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
tests.components.switch.test_mqtt
|
tests.components.switch.test_mqtt
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests mqtt switch.
|
Tests MQTT switch.
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
@ -107,4 +107,4 @@ class TestSensorMQTT(unittest.TestCase):
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
|
|
||||||
state = self.hass.states.get('switch.test')
|
state = self.hass.states.get('switch.test')
|
||||||
self.assertEqual(STATE_OFF, state.state)
|
self.assertEqual(STATE_OFF, state.state)
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
"""
|
"""
|
||||||
tests.components.switch.template
|
tests.components.switch.template
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests template switch.
|
Tests template switch.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
import homeassistant.components as core
|
import homeassistant.components as core
|
||||||
import homeassistant.components.switch as switch
|
import homeassistant.components.switch as switch
|
||||||
|
@ -27,7 +26,6 @@ class TestTemplateSwitch:
|
||||||
|
|
||||||
self.hass.services.register('test', 'automation', record_call)
|
self.hass.services.register('test', 'automation', record_call)
|
||||||
|
|
||||||
|
|
||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
""" Stop down stuff we started. """
|
""" Stop down stuff we started. """
|
||||||
self.hass.stop()
|
self.hass.stop()
|
||||||
|
@ -53,7 +51,6 @@ class TestTemplateSwitch:
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
state = self.hass.states.set('switch.test_state', STATE_ON)
|
state = self.hass.states.set('switch.test_state', STATE_ON)
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
|
|
||||||
|
@ -66,7 +63,6 @@ class TestTemplateSwitch:
|
||||||
state = self.hass.states.get('switch.test_template_switch')
|
state = self.hass.states.get('switch.test_template_switch')
|
||||||
assert state.state == STATE_OFF
|
assert state.state == STATE_OFF
|
||||||
|
|
||||||
|
|
||||||
def test_template_state_boolean_on(self):
|
def test_template_state_boolean_on(self):
|
||||||
assert switch.setup(self.hass, {
|
assert switch.setup(self.hass, {
|
||||||
'switch': {
|
'switch': {
|
||||||
|
@ -278,7 +274,6 @@ class TestTemplateSwitch:
|
||||||
|
|
||||||
assert 1 == len(self.calls)
|
assert 1 == len(self.calls)
|
||||||
|
|
||||||
|
|
||||||
def test_off_action(self):
|
def test_off_action(self):
|
||||||
assert switch.setup(self.hass, {
|
assert switch.setup(self.hass, {
|
||||||
'switch': {
|
'switch': {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_alexa
|
tests.components.test_alexa
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Home Assistant Alexa component does what it should do.
|
Tests Home Assistant Alexa component does what it should do.
|
||||||
"""
|
"""
|
||||||
|
@ -33,7 +33,7 @@ calls = []
|
||||||
@patch('homeassistant.components.http.util.get_local_ip',
|
@patch('homeassistant.components.http.util.get_local_ip',
|
||||||
return_value='127.0.0.1')
|
return_value='127.0.0.1')
|
||||||
def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name
|
def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name
|
||||||
"""Initalize a Home Assistant server for testing this module."""
|
""" Initalize a Home Assistant server for testing this module. """
|
||||||
global hass
|
global hass
|
||||||
|
|
||||||
hass = ha.HomeAssistant()
|
hass = ha.HomeAssistant()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_http
|
tests.components.test_api
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Home Assistant HTTP component does what it should do.
|
Tests Home Assistant HTTP component does what it should do.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_configurator
|
tests.components.test_configurator
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Configurator component.
|
Tests Configurator component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.test_conversation
|
tests.components.test_conversation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Conversation component.
|
Tests Conversation component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_demo
|
tests.test_component_demo
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests demo component.
|
Tests demo component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_device_sun_light_trigger
|
tests.test_component_device_sun_light_trigger
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests device sun light trigger component.
|
Tests device sun light trigger component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_http
|
tests.test_component_http
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Home Assistant HTTP component does what it should do.
|
Tests Home Assistant HTTP component does what it should do.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.test_graphite
|
tests.components.test_graphite
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests graphite feeder.
|
Tests graphite feeder.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_group
|
tests.test_component_group
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests the group compoments.
|
Tests the group compoments.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_history
|
tests.components.test_history
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests the history component.
|
Tests the history component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.test_influxdb
|
tests.components.test_influxdb
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests influxdb component.
|
Tests influxdb component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_core
|
tests.components.test_init
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests core compoments.
|
Tests core compoments.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
"""
|
"""
|
||||||
tests.components.introduction
|
tests.components.test_introduction
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Test introduction.
|
Test introduction.
|
||||||
|
|
||||||
This test is primarily to ensure that default components don't crash HASS.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_logbook
|
tests.components.test_logbook
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests the logbook component.
|
Tests the logbook component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_logger
|
tests.components.test_logger
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests logger component.
|
Tests logger component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_mqtt
|
tests.components.test_mqtt
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests MQTT component.
|
Tests MQTT component.
|
||||||
"""
|
"""
|
||||||
|
@ -63,10 +63,12 @@ class TestMQTT(unittest.TestCase):
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
|
|
||||||
self.assertEqual(1, len(self.calls))
|
self.assertEqual(1, len(self.calls))
|
||||||
self.assertEqual('test-topic',
|
self.assertEqual(
|
||||||
self.calls[0][0].data['service_data'][mqtt.ATTR_TOPIC])
|
'test-topic',
|
||||||
self.assertEqual('test-payload',
|
self.calls[0][0].data['service_data'][mqtt.ATTR_TOPIC])
|
||||||
self.calls[0][0].data['service_data'][mqtt.ATTR_PAYLOAD])
|
self.assertEqual(
|
||||||
|
'test-payload',
|
||||||
|
self.calls[0][0].data['service_data'][mqtt.ATTR_PAYLOAD])
|
||||||
|
|
||||||
def test_service_call_without_topic_does_not_publish(self):
|
def test_service_call_without_topic_does_not_publish(self):
|
||||||
self.hass.bus.fire(EVENT_CALL_SERVICE, {
|
self.hass.bus.fire(EVENT_CALL_SERVICE, {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_mqtt_eventstream
|
tests.components.test_mqtt_eventstream
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests MQTT eventstream component.
|
Tests MQTT eventstream component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
"""
|
"""
|
||||||
tests.components.proximity
|
tests.components.test_proximity
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests proximity component.
|
Tests proximity component.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
from homeassistant.components import proximity
|
from homeassistant.components import proximity
|
||||||
|
|
||||||
|
|
||||||
class TestProximity:
|
class TestProximity:
|
||||||
""" Test the Proximity component. """
|
""" Test the Proximity component. """
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class TestProximity:
|
||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
""" Stop down stuff we started. """
|
""" Stop down stuff we started. """
|
||||||
self.hass.stop()
|
self.hass.stop()
|
||||||
|
|
||||||
def test_proximity(self):
|
def test_proximity(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -45,12 +45,12 @@ class TestProximity:
|
||||||
assert state.state == 'not set'
|
assert state.state == 'not set'
|
||||||
assert state.attributes.get('nearest') == 'not set'
|
assert state.attributes.get('nearest') == 'not set'
|
||||||
assert state.attributes.get('dir_of_travel') == 'not set'
|
assert state.attributes.get('dir_of_travel') == 'not set'
|
||||||
|
|
||||||
self.hass.states.set('proximity.home', '0')
|
self.hass.states.set('proximity.home', '0')
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.state == '0'
|
assert state.state == '0'
|
||||||
|
|
||||||
def test_no_devices_in_config(self):
|
def test_no_devices_in_config(self):
|
||||||
assert not proximity.setup(self.hass, {
|
assert not proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -61,7 +61,7 @@ class TestProximity:
|
||||||
'tolerance': '1'
|
'tolerance': '1'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_no_tolerance_in_config(self):
|
def test_no_tolerance_in_config(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -75,7 +75,7 @@ class TestProximity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_no_ignored_zones_in_config(self):
|
def test_no_ignored_zones_in_config(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -87,7 +87,7 @@ class TestProximity:
|
||||||
'tolerance': '1'
|
'tolerance': '1'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_no_zone_in_config(self):
|
def test_no_zone_in_config(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -100,8 +100,8 @@ class TestProximity:
|
||||||
},
|
},
|
||||||
'tolerance': '1'
|
'tolerance': '1'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_device_tracker_test1_in_zone(self):
|
def test_device_tracker_test1_in_zone(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -115,7 +115,7 @@ class TestProximity:
|
||||||
'tolerance': '1'
|
'tolerance': '1'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'home',
|
'device_tracker.test1', 'home',
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ class TestProximity:
|
||||||
assert state.state == '0'
|
assert state.state == '0'
|
||||||
assert state.attributes.get('nearest') == 'test1'
|
assert state.attributes.get('nearest') == 'test1'
|
||||||
assert state.attributes.get('dir_of_travel') == 'arrived'
|
assert state.attributes.get('dir_of_travel') == 'arrived'
|
||||||
|
|
||||||
def test_device_trackers_in_zone(self):
|
def test_device_trackers_in_zone(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -143,7 +143,7 @@ class TestProximity:
|
||||||
'tolerance': '1'
|
'tolerance': '1'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'home',
|
'device_tracker.test1', 'home',
|
||||||
{
|
{
|
||||||
|
@ -164,7 +164,7 @@ class TestProximity:
|
||||||
assert state.state == '0'
|
assert state.state == '0'
|
||||||
assert (state.attributes.get('nearest') == 'test1, test2') or (state.attributes.get('nearest') == 'test2, test1')
|
assert (state.attributes.get('nearest') == 'test1, test2') or (state.attributes.get('nearest') == 'test2, test1')
|
||||||
assert state.attributes.get('dir_of_travel') == 'arrived'
|
assert state.attributes.get('dir_of_travel') == 'arrived'
|
||||||
|
|
||||||
def test_device_tracker_test1_away(self):
|
def test_device_tracker_test1_away(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -178,7 +178,7 @@ class TestProximity:
|
||||||
'tolerance': '1'
|
'tolerance': '1'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -190,7 +190,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test1'
|
assert state.attributes.get('nearest') == 'test1'
|
||||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||||
|
|
||||||
def test_device_tracker_test1_awayfurther(self):
|
def test_device_tracker_test1_awayfurther(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -203,7 +203,7 @@ class TestProximity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -226,7 +226,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test1'
|
assert state.attributes.get('nearest') == 'test1'
|
||||||
assert state.attributes.get('dir_of_travel') == 'away_from'
|
assert state.attributes.get('dir_of_travel') == 'away_from'
|
||||||
|
|
||||||
def test_device_tracker_test1_awaycloser(self):
|
def test_device_tracker_test1_awaycloser(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -239,7 +239,7 @@ class TestProximity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -262,7 +262,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test1'
|
assert state.attributes.get('nearest') == 'test1'
|
||||||
assert state.attributes.get('dir_of_travel') == 'towards'
|
assert state.attributes.get('dir_of_travel') == 'towards'
|
||||||
|
|
||||||
def test_all_device_trackers_in_ignored_zone(self):
|
def test_all_device_trackers_in_ignored_zone(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -275,7 +275,7 @@ class TestProximity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'work',
|
'device_tracker.test1', 'work',
|
||||||
{
|
{
|
||||||
|
@ -286,7 +286,7 @@ class TestProximity:
|
||||||
assert state.state == 'not set'
|
assert state.state == 'not set'
|
||||||
assert state.attributes.get('nearest') == 'not set'
|
assert state.attributes.get('nearest') == 'not set'
|
||||||
assert state.attributes.get('dir_of_travel') == 'not set'
|
assert state.attributes.get('dir_of_travel') == 'not set'
|
||||||
|
|
||||||
def test_device_tracker_test1_no_coordinates(self):
|
def test_device_tracker_test1_no_coordinates(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -300,7 +300,7 @@ class TestProximity:
|
||||||
'tolerance': '1'
|
'tolerance': '1'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -310,7 +310,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'not set'
|
assert state.attributes.get('nearest') == 'not set'
|
||||||
assert state.attributes.get('dir_of_travel') == 'not set'
|
assert state.attributes.get('dir_of_travel') == 'not set'
|
||||||
|
|
||||||
def test_device_tracker_test1_awayfurther_than_test2_first_test1(self):
|
def test_device_tracker_test1_awayfurther_than_test2_first_test1(self):
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
|
@ -336,7 +336,7 @@ class TestProximity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -359,7 +359,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test1'
|
assert state.attributes.get('nearest') == 'test1'
|
||||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||||
|
|
||||||
def test_device_tracker_test1_awayfurther_than_test2_first_test2(self):
|
def test_device_tracker_test1_awayfurther_than_test2_first_test2(self):
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
|
@ -385,7 +385,7 @@ class TestProximity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test2', 'not_home',
|
'device_tracker.test2', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -408,7 +408,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test1'
|
assert state.attributes.get('nearest') == 'test1'
|
||||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||||
|
|
||||||
def test_device_tracker_test1_awayfurther_test2_in_ignored_zone(self):
|
def test_device_tracker_test1_awayfurther_test2_in_ignored_zone(self):
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
|
@ -434,7 +434,7 @@ class TestProximity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -446,7 +446,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test1'
|
assert state.attributes.get('nearest') == 'test1'
|
||||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||||
|
|
||||||
def test_device_tracker_test1_awayfurther_than_test2_first_test1_than_test2_than_test1(self):
|
def test_device_tracker_test1_awayfurther_than_test2_first_test1_than_test2_than_test1(self):
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
|
@ -472,7 +472,7 @@ class TestProximity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -481,7 +481,7 @@ class TestProximity:
|
||||||
'longitude': 5.1
|
'longitude': 5.1
|
||||||
})
|
})
|
||||||
self.hass.pool.block_till_done()
|
self.hass.pool.block_till_done()
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test2', 'not_home',
|
'device_tracker.test2', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -515,7 +515,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test2'
|
assert state.attributes.get('nearest') == 'test2'
|
||||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||||
|
|
||||||
def test_device_tracker_test1_awayfurther_a_bit(self):
|
def test_device_tracker_test1_awayfurther_a_bit(self):
|
||||||
assert proximity.setup(self.hass, {
|
assert proximity.setup(self.hass, {
|
||||||
'proximity': {
|
'proximity': {
|
||||||
|
@ -529,7 +529,7 @@ class TestProximity:
|
||||||
'tolerance': 1000
|
'tolerance': 1000
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -552,7 +552,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test1'
|
assert state.attributes.get('nearest') == 'test1'
|
||||||
assert state.attributes.get('dir_of_travel') == 'stationary'
|
assert state.attributes.get('dir_of_travel') == 'stationary'
|
||||||
|
|
||||||
def test_device_tracker_test1_nearest_after_test2_in_ignored_zone(self):
|
def test_device_tracker_test1_nearest_after_test2_in_ignored_zone(self):
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
|
@ -578,7 +578,7 @@ class TestProximity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test1', 'not_home',
|
'device_tracker.test1', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -590,7 +590,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test1'
|
assert state.attributes.get('nearest') == 'test1'
|
||||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test2', 'not_home',
|
'device_tracker.test2', 'not_home',
|
||||||
{
|
{
|
||||||
|
@ -602,7 +602,7 @@ class TestProximity:
|
||||||
state = self.hass.states.get('proximity.home')
|
state = self.hass.states.get('proximity.home')
|
||||||
assert state.attributes.get('nearest') == 'test2'
|
assert state.attributes.get('nearest') == 'test2'
|
||||||
assert state.attributes.get('dir_of_travel') == 'unknown'
|
assert state.attributes.get('dir_of_travel') == 'unknown'
|
||||||
|
|
||||||
self.hass.states.set(
|
self.hass.states.set(
|
||||||
'device_tracker.test2', 'work',
|
'device_tracker.test2', 'work',
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_recorder
|
tests.components.test_recorder
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Recorder component.
|
Tests Recorder component.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""
|
"""
|
||||||
tests.test_shell_command
|
tests.components.test_shell_command
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests demo component.
|
Tests Shell command component.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.test_splunk
|
tests.components.test_splunk
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests splunk component.
|
Tests splunk component.
|
||||||
"""
|
"""
|
||||||
|
@ -40,7 +40,6 @@ class TestSplunk(unittest.TestCase):
|
||||||
self.assertEqual(EVENT_STATE_CHANGED,
|
self.assertEqual(EVENT_STATE_CHANGED,
|
||||||
hass.bus.listen.call_args_list[0][0][0])
|
hass.bus.listen.call_args_list[0][0][0])
|
||||||
|
|
||||||
|
|
||||||
def _setup(self, mock_requests):
|
def _setup(self, mock_requests):
|
||||||
self.mock_post = mock_requests.post
|
self.mock_post = mock_requests.post
|
||||||
self.mock_request_exception = Exception
|
self.mock_request_exception = Exception
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""
|
"""
|
||||||
tests.components.test_statsd
|
tests.components.test_statsd
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests statsd feeder.
|
Tests StatsD feeder.
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_component_sun
|
tests.components.test_sun
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Sun component.
|
Tests Sun component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_updater
|
tests.components.test_updater
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests updater component.
|
Tests updater component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
"""
|
||||||
|
tests.components.test_weblink
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Tests weblink component.
|
||||||
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.components.test_zone
|
tests.components.test_zone
|
||||||
±±±~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests zone component.
|
Tests zone component.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||||
TEMP_CELCIUS,
|
TEMP_CELCIUS,
|
||||||
)
|
)
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
from homeassistant.components import switch, thermostat
|
from homeassistant.components import thermostat
|
||||||
|
|
||||||
|
|
||||||
entity = 'thermostat.test'
|
entity = 'thermostat.test'
|
||||||
|
@ -138,4 +138,3 @@ class TestThermostatHeatControl(unittest.TestCase):
|
||||||
|
|
||||||
self.hass.services.register('switch', SERVICE_TURN_ON, log_call)
|
self.hass.services.register('switch', SERVICE_TURN_ON, log_call)
|
||||||
self.hass.services.register('switch', SERVICE_TURN_OFF, log_call)
|
self.hass.services.register('switch', SERVICE_TURN_OFF, log_call)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
custom_components.device_tracker.test
|
config.custom_components.device_tracker.test
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Provides a mock device scanner.
|
Provides a mock device scanner.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
custom_components.light.test
|
config.custom_components.light.test
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Provides a mock switch platform.
|
Provides a mock switch platform.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
custom_components.switch.test
|
config.custom_components.switch.test
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Provides a mock switch platform.
|
Provides a mock switch platform.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_helper_entity
|
tests.helpers.test_entity
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests the entity helper.
|
Tests the entity helper.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_helper_entity_component
|
tests.helpers.test_entity_component
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests the entity component helper.
|
Tests the entity component helper.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.helpers.event_test
|
tests.helpers.event_test
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests event helpers.
|
Tests event helpers.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.helpers.test_event_decorators
|
tests.helpers.test_event_decorators
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests event decorator helpers.
|
Tests event decorator helpers.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_helpers
|
tests.helpers.test_init
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests component helpers.
|
Tests component helpers.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -15,9 +15,7 @@ from tests.common import get_test_home_assistant, mock_service
|
||||||
|
|
||||||
|
|
||||||
class TestServiceHelpers(unittest.TestCase):
|
class TestServiceHelpers(unittest.TestCase):
|
||||||
"""
|
""" Tests the Home Assistant service helpers. """
|
||||||
Tests the Home Assistant service helpers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self): # pylint: disable=invalid-name
|
def setUp(self): # pylint: disable=invalid-name
|
||||||
""" things to be run when tests are started. """
|
""" things to be run when tests are started. """
|
||||||
|
|
|
@ -24,12 +24,10 @@ from tests.common import get_test_home_assistant, mock_service
|
||||||
|
|
||||||
|
|
||||||
class TestStateHelpers(unittest.TestCase):
|
class TestStateHelpers(unittest.TestCase):
|
||||||
"""
|
""" Tests the Home Assistant event helpers. """
|
||||||
Tests the Home Assistant event helpers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self): # pylint: disable=invalid-name
|
def setUp(self): # pylint: disable=invalid-name
|
||||||
""" things to be run when tests are started. """
|
""" Things to be run when tests are started. """
|
||||||
self.hass = get_test_home_assistant()
|
self.hass = get_test_home_assistant()
|
||||||
core_components.setup(self.hass, {})
|
core_components.setup(self.hass, {})
|
||||||
|
|
||||||
|
@ -166,9 +164,9 @@ class TestStateHelpers(unittest.TestCase):
|
||||||
|
|
||||||
def test_as_number_coercion(self):
|
def test_as_number_coercion(self):
|
||||||
for _state in ('0', '0.0'):
|
for _state in ('0', '0.0'):
|
||||||
self.assertEqual(
|
self.assertEqual(0.0, float(
|
||||||
0.0, float(state.state_as_number(
|
state.state_as_number(
|
||||||
ha.State('domain.test', _state, {}))))
|
ha.State('domain.test', _state, {}))))
|
||||||
for _state in ('1', '1.0'):
|
for _state in ('1', '1.0'):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1.0, float(state.state_as_number(
|
1.0, float(state.state_as_number(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_config
|
tests.test_config
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests config utils.
|
Tests config utils.
|
||||||
"""
|
"""
|
||||||
|
@ -102,7 +102,6 @@ class TestConfig(unittest.TestCase):
|
||||||
with self.assertRaises(HomeAssistantError):
|
with self.assertRaises(HomeAssistantError):
|
||||||
config_util.load_yaml_config_file(YAML_PATH)
|
config_util.load_yaml_config_file(YAML_PATH)
|
||||||
|
|
||||||
|
|
||||||
def test_load_yaml_config_preserves_key_order(self):
|
def test_load_yaml_config_preserves_key_order(self):
|
||||||
with open(YAML_PATH, 'w') as f:
|
with open(YAML_PATH, 'w') as f:
|
||||||
f.write('hello: 0\n')
|
f.write('hello: 0\n')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_core
|
tests.test_core
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Provides tests to verify that Home Assistant core works.
|
Provides tests to verify that Home Assistant core works.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
ha_tests.test_loader
|
tests.test_loader
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Provides tests to verify that we can load components.
|
Provides tests to verify that we can load components.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.remote
|
tests.remote
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Home Assistant remote methods and classes.
|
Tests Home Assistant remote methods and classes.
|
||||||
Uses port 8122 for master, 8123 for slave
|
Uses port 8122 for master, 8123 for slave
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
"""
|
"""
|
||||||
|
tests.util.test_color
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Home Assistant color util methods.
|
Tests Home Assistant color util methods.
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_util
|
tests.util.test_dt
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Home Assistant date util methods.
|
Tests Home Assistant date util methods.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
tests.test_util
|
tests.util.test_init
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Home Assistant util methods.
|
Tests Home Assistant util methods.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
"""
|
"""
|
||||||
|
tests.util.test_packages
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Home Assistant package util methods.
|
Tests Home Assistant package util methods.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
|
@ -18,26 +21,26 @@ TEST_ZIP_REQ = 'file://{}#{}' \
|
||||||
|
|
||||||
|
|
||||||
class TestPackageUtil(unittest.TestCase):
|
class TestPackageUtil(unittest.TestCase):
|
||||||
""" Tests for homeassistant.util.package module """
|
""" Tests for homeassistant.util.package module. """
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
""" Create local library for testing """
|
""" Create local library for testing. """
|
||||||
self.tmp_dir = tempfile.TemporaryDirectory()
|
self.tmp_dir = tempfile.TemporaryDirectory()
|
||||||
self.lib_dir = os.path.join(self.tmp_dir.name, 'lib')
|
self.lib_dir = os.path.join(self.tmp_dir.name, 'lib')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
""" Remove local library """
|
""" Remove local library. """
|
||||||
self.tmp_dir.cleanup()
|
self.tmp_dir.cleanup()
|
||||||
|
|
||||||
def test_install_existing_package(self):
|
def test_install_existing_package(self):
|
||||||
""" Test an install attempt on an existing package """
|
""" Test an install attempt on an existing package. """
|
||||||
self.assertTrue(package.check_package_exists(
|
self.assertTrue(package.check_package_exists(
|
||||||
TEST_EXIST_REQ, self.lib_dir))
|
TEST_EXIST_REQ, self.lib_dir))
|
||||||
|
|
||||||
self.assertTrue(package.install_package(TEST_EXIST_REQ))
|
self.assertTrue(package.install_package(TEST_EXIST_REQ))
|
||||||
|
|
||||||
def test_install_package_zip(self):
|
def test_install_package_zip(self):
|
||||||
""" Test an install attempt from a zip path """
|
""" Test an install attempt from a zip path. """
|
||||||
self.assertFalse(package.check_package_exists(
|
self.assertFalse(package.check_package_exists(
|
||||||
TEST_ZIP_REQ, self.lib_dir))
|
TEST_ZIP_REQ, self.lib_dir))
|
||||||
self.assertFalse(package.check_package_exists(
|
self.assertFalse(package.check_package_exists(
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""
|
"""
|
||||||
tests.test_util
|
tests.util.test_template
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Tests Home Assistant util methods.
|
Tests Home Assistant template util methods.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-many-public-methods
|
# pylint: disable=too-many-public-methods
|
||||||
import unittest
|
import unittest
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue