Update for file header, docstrings, and PEP8/PEP257

This commit is contained in:
Fabian Affolter 2016-02-13 14:19:11 +01:00
parent 34b91cf6ce
commit 00afaac54c
74 changed files with 212 additions and 211 deletions

View file

@ -1,3 +1,9 @@
"""
tests.__init__
~~~~~~~~~~~~~~
Tests initialization.
"""
import betamax
from homeassistant.util import location

View file

@ -1,6 +1,6 @@
"""
tests.helper
~~~~~~~~~~~~~
tests.common
~~~~~~~~~~~~
Helper method for writing tests.
"""

View file

@ -1,6 +1,7 @@
"""
tests.components.automation.test_init
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests automation component.
"""
import unittest

View file

@ -267,7 +267,7 @@ class TestAutomationNumericState(unittest.TestCase):
}
}))
# 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.assertEqual(1, len(self.calls))
@ -285,7 +285,7 @@ class TestAutomationNumericState(unittest.TestCase):
}
}))
# 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.assertEqual(0, len(self.calls))
@ -304,7 +304,7 @@ class TestAutomationNumericState(unittest.TestCase):
}
}))
# 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.assertEqual(1, len(self.calls))
@ -323,7 +323,7 @@ class TestAutomationNumericState(unittest.TestCase):
}
}))
# 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.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
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.assertEqual(0, len(self.calls))
@ -380,7 +380,7 @@ class TestAutomationNumericState(unittest.TestCase):
}
}))
# 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.assertEqual(1, len(self.calls))
@ -399,7 +399,7 @@ class TestAutomationNumericState(unittest.TestCase):
}
}))
# 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.assertEqual(1, len(self.calls))
@ -418,7 +418,7 @@ class TestAutomationNumericState(unittest.TestCase):
}
}))
# 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.assertEqual(1, len(self.calls))
@ -437,7 +437,7 @@ class TestAutomationNumericState(unittest.TestCase):
}
}))
# 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.assertEqual(0, len(self.calls))

View file

@ -1,6 +1,6 @@
"""
tests.components.automation.test_state
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests state automation.
"""

View file

@ -1,6 +1,6 @@
"""
tests.components.automation.test_template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests template automation.
"""

View file

@ -1,6 +1,6 @@
"""
tests.components.automation.test_location
±±±~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.automation.test_zone
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests location automation.
"""

View file

@ -1,10 +1,9 @@
"""
tests.components.binary_sensor.command_sensor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests command binary sensor.
"""
import unittest
import homeassistant.core as ha

View file

@ -1,6 +1,6 @@
"""
tests.test_component_device_tracker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.device_tracker.test_init
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests the device tracker compoments.
"""

View file

@ -1,10 +1,9 @@
"""
tests.components.device_tracker.locative
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.device_tracker.test_locative
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests the locative device tracker component.
"""
import unittest
from unittest.mock import patch
@ -24,7 +23,8 @@ hass = None
def _url(data={}):
""" 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)
@ -60,6 +60,7 @@ def tearDownModule(): # pylint: disable=invalid-name
""" Stops the Home Assistant server. """
hass.stop()
# Stub out update_config or else Travis CI raises an exception
@patch('homeassistant.components.device_tracker.update_config')
class TestLocative(unittest.TestCase):
@ -114,7 +115,6 @@ class TestLocative(unittest.TestCase):
req = requests.get(_url(copy))
self.assertEqual(422, req.status_code)
def test_enter_and_exit(self, update_config):
""" Test when there is a known zone """
data = {
@ -166,7 +166,6 @@ class TestLocative(unittest.TestCase):
state_name = hass.states.get('{}.{}'.format('device_tracker', data['device'])).state
self.assertEqual(state_name, 'work')
def test_exit_after_enter(self, update_config):
""" Test when an exit message comes after an enter message """

View file

@ -1,3 +1,9 @@
"""
tests.components.device_tracker.test_mqtt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests the MQTT device tracker component.
"""
import unittest
import os

View file

@ -1,8 +1,8 @@
"""
tests.components.sensor.template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.device_tracker.test_owntracks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests template sensor.
Tests Owntracks device tracker.
"""
import json
import os
@ -111,14 +111,14 @@ class TestDeviceTrackerOwnTracks(unittest.TestCase):
})
self.hass.states.set(
'zone.passive', 'zoning',
{
'name': 'zone',
'latitude': 3.0,
'longitude': 1.0,
'radius': 10,
'passive': True
})
'zone.passive', 'zoning',
{
'name': 'zone',
'latitude': 3.0,
'longitude': 1.0,
'radius': 10,
'passive': True
})
# Clear state between teste
self.hass.states.set(DEVICE_TRACKER_STATE, None)
owntracks.REGIONS_ENTERED = defaultdict(list)

View file

@ -1,6 +1,6 @@
"""
tests.components.garage_door.test_demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests demo garage door component.
"""

View file

@ -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
import unittest
@ -18,7 +18,7 @@ from tests.common import mock_service, get_test_home_assistant
class TestLight(unittest.TestCase):
""" Test the switch module. """
""" Test the light module. """
def setUp(self): # pylint: disable=invalid-name
self.hass = get_test_home_assistant()

View file

@ -1,6 +1,6 @@
"""
tests.components.light.test_mqtt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests mqtt light.

View file

@ -6,13 +6,9 @@ Tests demo media_player component.
"""
import unittest
from unittest.mock import patch
from pprint import pprint
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
entity_id = 'media_player.walkman'
@ -138,4 +134,3 @@ class TestDemoMediaPlayer(unittest.TestCase):
mp.media_seek(self.hass, 100, ent_id)
self.hass.pool.block_till_done()
assert mock_seek.called

View file

@ -1,7 +1,8 @@
"""
tests.components.notify.test_demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests notify demo component
Tests notify demo component.
"""
import unittest

View file

@ -1,6 +1,6 @@
"""
tests.components.rollershutter.test_mqtt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests MQTT rollershutter.
"""

View file

@ -1,10 +1,9 @@
"""
tests.components.sensor.command_sensor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.sensor.test_command_sensor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests command sensor.
"""
import unittest
import homeassistant.core as ha
@ -12,7 +11,7 @@ from homeassistant.components.sensor import command_sensor
class TestCommandSensorSensor(unittest.TestCase):
""" Test the Template sensor. """
""" Test the Command line sensor. """
def setUp(self):
self.hass = ha.HomeAssistant()
@ -22,7 +21,7 @@ class TestCommandSensorSensor(unittest.TestCase):
self.hass.stop()
def test_setup(self):
""" Test sensor setup """
""" Test sensor setup. """
config = {'name': 'Test',
'unit_of_measurement': 'in',
'command': 'echo 5'}
@ -43,7 +42,7 @@ class TestCommandSensorSensor(unittest.TestCase):
self.assertEqual('5', entity.state)
def test_setup_bad_config(self):
""" Test setup with a bad config """
""" Test setup with a bad configuration. """
config = {}
devices = []
@ -59,7 +58,7 @@ class TestCommandSensorSensor(unittest.TestCase):
self.assertEqual(0, len(devices))
def test_template(self):
""" Test command sensor with template """
""" Test command sensor with template. """
data = command_sensor.CommandSensorData('echo 50')
entity = command_sensor.CommandSensor(
@ -68,7 +67,7 @@ class TestCommandSensorSensor(unittest.TestCase):
self.assertEqual(5, float(entity.state))
def test_bad_command(self):
""" Test bad command """
""" Test bad command. """
data = command_sensor.CommandSensorData('asdfasdf')
data.update()

View file

@ -1,6 +1,6 @@
"""
tests.components.sensor.test_mfi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests mFi sensor.
"""

View file

@ -2,7 +2,7 @@
tests.components.sensor.test_mqtt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests mqtt sensor.
Tests MQTT sensor.
"""
import unittest

View file

@ -1,10 +1,9 @@
"""
tests.components.sensor.template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.sensor.test_template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests template sensor.
"""
import homeassistant.core as ha
import homeassistant.components.sensor as sensor

View file

@ -1,6 +1,6 @@
"""
tests.components.sensor.test_yr
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Yr sensor.
"""
@ -73,7 +73,7 @@ class TestSensorYr:
assert '1025.1' == state.state
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
state = self.hass.states.get('sensor.yr_humidity')

View file

@ -1,6 +1,6 @@
"""
tests.components.switch.test_command_switch
~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests command switch.
"""
@ -55,7 +55,6 @@ class TestCommandSwitch(unittest.TestCase):
state = self.hass.states.get('switch.test')
self.assertEqual(STATE_OFF, state.state)
def test_state_value(self):
with tempfile.TemporaryDirectory() as tempdirname:
path = os.path.join(tempdirname, 'switch_status')
@ -79,7 +78,7 @@ class TestCommandSwitch(unittest.TestCase):
switch.turn_on(self.hass, 'switch.test')
self.hass.pool.block_till_done()
state = self.hass.states.get('switch.test')
self.assertEqual(STATE_ON, state.state)
@ -89,7 +88,6 @@ class TestCommandSwitch(unittest.TestCase):
state = self.hass.states.get('switch.test')
self.assertEqual(STATE_OFF, state.state)
def test_state_json_value(self):
with tempfile.TemporaryDirectory() as tempdirname:
path = os.path.join(tempdirname, 'switch_status')

View file

@ -1,6 +1,6 @@
"""
tests.test_component_switch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.switch.test_init
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests switch component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.components.switch.test_mfi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests mFi switch.
"""

View file

@ -2,7 +2,7 @@
tests.components.switch.test_mqtt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests mqtt switch.
Tests MQTT switch.
"""
import unittest
@ -107,4 +107,4 @@ class TestSensorMQTT(unittest.TestCase):
self.hass.pool.block_till_done()
state = self.hass.states.get('switch.test')
self.assertEqual(STATE_OFF, state.state)
self.assertEqual(STATE_OFF, state.state)

View file

@ -1,10 +1,9 @@
"""
tests.components.switch.template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests template switch.
"""
import homeassistant.core as ha
import homeassistant.components as core
import homeassistant.components.switch as switch
@ -27,7 +26,6 @@ class TestTemplateSwitch:
self.hass.services.register('test', 'automation', record_call)
def teardown_method(self, method):
""" Stop down stuff we started. """
self.hass.stop()
@ -53,7 +51,6 @@ class TestTemplateSwitch:
}
})
state = self.hass.states.set('switch.test_state', STATE_ON)
self.hass.pool.block_till_done()
@ -66,7 +63,6 @@ class TestTemplateSwitch:
state = self.hass.states.get('switch.test_template_switch')
assert state.state == STATE_OFF
def test_template_state_boolean_on(self):
assert switch.setup(self.hass, {
'switch': {
@ -278,7 +274,6 @@ class TestTemplateSwitch:
assert 1 == len(self.calls)
def test_off_action(self):
assert switch.setup(self.hass, {
'switch': {

View file

@ -1,6 +1,6 @@
"""
tests.test_component_alexa
~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_alexa
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Home Assistant Alexa component does what it should do.
"""
@ -33,7 +33,7 @@ calls = []
@patch('homeassistant.components.http.util.get_local_ip',
return_value='127.0.0.1')
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
hass = ha.HomeAssistant()

View file

@ -1,6 +1,6 @@
"""
tests.test_component_http
~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_api
~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Home Assistant HTTP component does what it should do.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_component_configurator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_configurator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Configurator component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.components.test_conversation
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Conversation component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_component_demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
Tests demo component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_component_device_sun_light_trigger
~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests device sun light trigger component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_component_http
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Home Assistant HTTP component does what it should do.
"""

View file

@ -1,6 +1,6 @@
"""
tests.components.test_graphite
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests graphite feeder.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_component_group
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests the group compoments.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_component_history
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_history
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests the history component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.components.test_influxdb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests influxdb component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_component_core
~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_init
~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests core compoments.
"""

View file

@ -1,12 +1,9 @@
"""
tests.components.introduction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_introduction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Test introduction.
This test is primarily to ensure that default components don't crash HASS.
"""
import unittest
import homeassistant.core as ha

View file

@ -1,6 +1,6 @@
"""
tests.test_component_logbook
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_logbook
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests the logbook component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_logger
~~~~~~~~~~~~~~~~~~
tests.components.test_logger
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests logger component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_component_mqtt
~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_mqtt
~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests MQTT component.
"""
@ -63,10 +63,12 @@ class TestMQTT(unittest.TestCase):
self.hass.pool.block_till_done()
self.assertEqual(1, len(self.calls))
self.assertEqual('test-topic',
self.calls[0][0].data['service_data'][mqtt.ATTR_TOPIC])
self.assertEqual('test-payload',
self.calls[0][0].data['service_data'][mqtt.ATTR_PAYLOAD])
self.assertEqual(
'test-topic',
self.calls[0][0].data['service_data'][mqtt.ATTR_TOPIC])
self.assertEqual(
'test-payload',
self.calls[0][0].data['service_data'][mqtt.ATTR_PAYLOAD])
def test_service_call_without_topic_does_not_publish(self):
self.hass.bus.fire(EVENT_CALL_SERVICE, {

View file

@ -1,6 +1,6 @@
"""
tests.test_component_mqtt_eventstream
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_mqtt_eventstream
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests MQTT eventstream component.
"""

View file

@ -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',
{

View file

@ -1,5 +1,5 @@
"""
tests.test_component_recorder
tests.components.test_recorder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Recorder component.

View file

@ -1,8 +1,8 @@
"""
tests.test_shell_command
~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_shell_command
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests demo component.
Tests Shell command component.
"""
import os
import tempfile

View file

@ -1,6 +1,6 @@
"""
tests.components.test_splunk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests splunk component.
"""
@ -40,7 +40,6 @@ class TestSplunk(unittest.TestCase):
self.assertEqual(EVENT_STATE_CHANGED,
hass.bus.listen.call_args_list[0][0][0])
def _setup(self, mock_requests):
self.mock_post = mock_requests.post
self.mock_request_exception = Exception

View file

@ -1,8 +1,8 @@
"""
tests.components.test_statsd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests statsd feeder.
Tests StatsD feeder.
"""
import unittest
from unittest import mock

View file

@ -1,6 +1,6 @@
"""
tests.test_component_sun
~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.components.test_sun
~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Sun component.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_updater
~~~~~~~~~~~~~~~~~~
tests.components.test_updater
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests updater component.
"""

View file

@ -1,4 +1,9 @@
# -*- coding: utf-8 -*-
"""
tests.components.test_weblink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests weblink component.
"""
import unittest
import homeassistant.core as ha

View file

@ -1,6 +1,6 @@
"""
tests.components.test_zone
±±±~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests zone component.
"""

View file

@ -15,7 +15,7 @@ from homeassistant.const import (
TEMP_CELCIUS,
)
import homeassistant.core as ha
from homeassistant.components import switch, thermostat
from homeassistant.components import thermostat
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_OFF, log_call)

View file

@ -1,6 +1,6 @@
"""
custom_components.device_tracker.test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
config.custom_components.device_tracker.test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides a mock device scanner.
"""

View file

@ -1,6 +1,6 @@
"""
custom_components.light.test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
config.custom_components.light.test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides a mock switch platform.

View file

@ -1,6 +1,6 @@
"""
custom_components.switch.test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
config.custom_components.switch.test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides a mock switch platform.

View file

@ -1,6 +1,6 @@
"""
tests.test_helper_entity
~~~~~~~~~~~~~~~~~~~~~~~~
tests.helpers.test_entity
~~~~~~~~~~~~~~~~~~~~~~~~~
Tests the entity helper.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_helper_entity_component
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests.helpers.test_entity_component
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests the entity component helper.
"""

View file

@ -1,6 +1,6 @@
"""
tests.helpers.event_test
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~
Tests event helpers.
"""

View file

@ -1,6 +1,6 @@
"""
tests.helpers.test_event_decorators
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests event decorator helpers.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_helpers
~~~~~~~~~~~~~~~~~~~~
tests.helpers.test_init
~~~~~~~~~~~~~~~~~~~~~~~
Tests component helpers.
"""

View file

@ -15,9 +15,7 @@ from tests.common import get_test_home_assistant, mock_service
class TestServiceHelpers(unittest.TestCase):
"""
Tests the Home Assistant service helpers.
"""
""" Tests the Home Assistant service helpers. """
def setUp(self): # pylint: disable=invalid-name
""" things to be run when tests are started. """

View file

@ -24,12 +24,10 @@ from tests.common import get_test_home_assistant, mock_service
class TestStateHelpers(unittest.TestCase):
"""
Tests the Home Assistant event helpers.
"""
""" Tests the Home Assistant event helpers. """
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()
core_components.setup(self.hass, {})
@ -166,9 +164,9 @@ class TestStateHelpers(unittest.TestCase):
def test_as_number_coercion(self):
for _state in ('0', '0.0'):
self.assertEqual(
0.0, float(state.state_as_number(
ha.State('domain.test', _state, {}))))
self.assertEqual(0.0, float(
state.state_as_number(
ha.State('domain.test', _state, {}))))
for _state in ('1', '1.0'):
self.assertEqual(
1.0, float(state.state_as_number(

View file

@ -1,6 +1,6 @@
"""
tests.test_config
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~
Tests config utils.
"""
@ -102,7 +102,6 @@ class TestConfig(unittest.TestCase):
with self.assertRaises(HomeAssistantError):
config_util.load_yaml_config_file(YAML_PATH)
def test_load_yaml_config_preserves_key_order(self):
with open(YAML_PATH, 'w') as f:
f.write('hello: 0\n')

View file

@ -1,6 +1,6 @@
"""
tests.test_core
~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~
Provides tests to verify that Home Assistant core works.
"""

View file

@ -1,6 +1,6 @@
"""
ha_tests.test_loader
~~~~~~~~~~~~~~~~~~~~~~
tests.test_loader
~~~~~~~~~~~~~~~~~
Provides tests to verify that we can load components.
"""

View file

@ -1,6 +1,6 @@
"""
tests.remote
~~~~~~~~~~~~~~
~~~~~~~~~~~~
Tests Home Assistant remote methods and classes.
Uses port 8122 for master, 8123 for slave

View file

@ -1,4 +1,7 @@
"""
tests.util.test_color
~~~~~~~~~~~~~~~~~~~~~
Tests Home Assistant color util methods.
"""
import unittest

View file

@ -1,6 +1,6 @@
"""
tests.test_util
~~~~~~~~~~~~~~~~~
tests.util.test_dt
~~~~~~~~~~~~~~~~~~
Tests Home Assistant date util methods.
"""

View file

@ -1,6 +1,6 @@
"""
tests.test_util
~~~~~~~~~~~~~~~~~
tests.util.test_init
~~~~~~~~~~~~~~~~~~~~
Tests Home Assistant util methods.
"""

View file

@ -1,4 +1,7 @@
"""
tests.util.test_packages
~~~~~~~~~~~~~~~~~~~~~~~~
Tests Home Assistant package util methods.
"""
import os
@ -18,26 +21,26 @@ TEST_ZIP_REQ = 'file://{}#{}' \
class TestPackageUtil(unittest.TestCase):
""" Tests for homeassistant.util.package module """
""" Tests for homeassistant.util.package module. """
def setUp(self):
""" Create local library for testing """
""" Create local library for testing. """
self.tmp_dir = tempfile.TemporaryDirectory()
self.lib_dir = os.path.join(self.tmp_dir.name, 'lib')
def tearDown(self):
""" Remove local library """
""" Remove local library. """
self.tmp_dir.cleanup()
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(
TEST_EXIST_REQ, self.lib_dir))
self.assertTrue(package.install_package(TEST_EXIST_REQ))
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(
TEST_ZIP_REQ, self.lib_dir))
self.assertFalse(package.check_package_exists(

View file

@ -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
import unittest