Skip to content

Commit

Permalink
Fix up docstring for tests (home-assistant#5090)
Browse files Browse the repository at this point in the history
  • Loading branch information
kellerza authored Dec 28, 2016
1 parent 98efbbc commit f0b1874
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 59 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
"""Home Assistant setup script."""
import os
from setuptools import setup, find_packages
from homeassistant.const import (__version__, PROJECT_PACKAGE_NAME,
Expand Down
4 changes: 4 additions & 0 deletions tests/components/automation/test_litejet.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def teardown_method(self, method):
self.hass.stop()

def simulate_press(self, number):
"""Test to simulate a press."""
_LOGGER.info('*** simulate press of %d', number)
callback = self.switch_pressed_callbacks.get(number)
with mock.patch('homeassistant.helpers.condition.dt_util.utcnow',
Expand All @@ -80,6 +81,7 @@ def simulate_press(self, number):
self.hass.block_till_done()

def simulate_release(self, number):
"""Test to simulate releasing."""
_LOGGER.info('*** simulate release of %d', number)
callback = self.switch_released_callbacks.get(number)
with mock.patch('homeassistant.helpers.condition.dt_util.utcnow',
Expand All @@ -89,6 +91,7 @@ def simulate_release(self, number):
self.hass.block_till_done()

def simulate_time(self, delta):
"""Test to simulate time."""
_LOGGER.info(
'*** simulate time change by %s: %s',
delta,
Expand All @@ -102,6 +105,7 @@ def simulate_time(self, delta):
_LOGGER.info('done with now=%s', dt_util.utcnow())

def setup_automation(self, trigger):
"""Test setting up the automation."""
assert bootstrap.setup_component(self.hass, automation.DOMAIN, {
automation.DOMAIN: [
{
Expand Down
16 changes: 4 additions & 12 deletions tests/components/climate/test_generic_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ def test_set_target_temp_heater_off(self):
self.assertEqual(ENT_SWITCH, call.data['entity_id'])

def test_temp_change_heater_on_within_tolerance(self):
"""Test if temperature change doesn't turn heater on within
tolerance.
"""
"""Test if temperature change doesn't turn on within tolerance."""
self._setup_switch(False)
climate.set_temperature(self.hass, 30)
self.hass.block_till_done()
Expand All @@ -206,9 +204,7 @@ def test_temp_change_heater_on_outside_tolerance(self):
self.assertEqual(ENT_SWITCH, call.data['entity_id'])

def test_temp_change_heater_off_within_tolerance(self):
"""Test if temperature change doesn't turn heater off within
tolerance.
"""
"""Test if temperature change doesn't turn off within tolerance."""
self._setup_switch(True)
climate.set_temperature(self.hass, 30)
self.hass.block_till_done()
Expand Down Expand Up @@ -296,9 +292,7 @@ def test_set_target_temp_ac_on(self):
self.assertEqual(ENT_SWITCH, call.data['entity_id'])

def test_temp_change_ac_off_within_tolerance(self):
"""Test if temperature change doesn't turn ac off within
tolerance.
"""
"""Test if temperature change doesn't turn ac off within tolerance."""
self._setup_switch(True)
climate.set_temperature(self.hass, 30)
self.hass.block_till_done()
Expand All @@ -320,9 +314,7 @@ def test_set_temp_change_ac_off_outside_tolerance(self):
self.assertEqual(ENT_SWITCH, call.data['entity_id'])

def test_temp_change_ac_on_within_tolerance(self):
"""Test if temperature change doesn't turn ac on within
tolerance.
"""
"""Test if temperature change doesn't turn ac on within tolerance."""
self._setup_switch(False)
climate.set_temperature(self.hass, 25)
self.hass.block_till_done()
Expand Down
1 change: 1 addition & 0 deletions tests/components/emulated_hue/test_init.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test the Emulated Hue component."""
from unittest.mock import patch

from homeassistant.components.emulated_hue import Config, _LOGGER
Expand Down
4 changes: 2 additions & 2 deletions tests/components/http/test_ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_access_from_banned_ip(self):
assert req.status_code == 403

def test_access_from_banned_ip_when_ban_is_off(self):
"""Test accessing to server from banned IP when feature is off"""
"""Test accessing to server from banned IP when feature is off."""
hass.http.app[KEY_BANS_ENABLED] = False
for remote_addr in BANNED_IPS:
with patch('homeassistant.components.http.'
Expand All @@ -87,7 +87,7 @@ def test_access_from_banned_ip_when_ban_is_off(self):
assert req.status_code == 200

def test_ip_bans_file_creation(self):
"""Testing if banned IP file created"""
"""Testing if banned IP file created."""
hass.http.app[KEY_BANS_ENABLED] = True
hass.http.app[KEY_LOGIN_THRESHOLD] = 1

Expand Down
3 changes: 1 addition & 2 deletions tests/components/http/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class TestCors:

def test_cors_allowed_with_password_in_url(self):
"""Test cross origin resource sharing with password in url."""

req = requests.get(_url(const.URL_API),
params={'api_password': API_PASSWORD},
headers={const.HTTP_HEADER_ORIGIN: HTTP_BASE_URL})
Expand Down Expand Up @@ -119,6 +118,7 @@ def test_cors_preflight_allowed(self):


class TestView(http.HomeAssistantView):
"""Test the HTTP views."""

name = 'test'
url = '/hello'
Expand Down Expand Up @@ -159,7 +159,6 @@ def test_registering_view_while_running(hass, test_client):

def test_api_base_url(loop):
"""Test setting api url."""

hass = MagicMock()
hass.loop = loop

Expand Down
6 changes: 2 additions & 4 deletions tests/components/light/test_litejet.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def on_load_deactivated(number, callback):
self.mock_lj.get_load_level.reset_mock()

def light(self):
"""Test for main light entity."""
return self.hass.states.get(ENTITY_LIGHT)

def other_light(self):
"""Test the other light."""
return self.hass.states.get(ENTITY_OTHER_LIGHT)

def teardown_method(self, method):
Expand All @@ -71,7 +73,6 @@ def teardown_method(self, method):

def test_on_brightness(self):
"""Test turning the light on with brightness."""

assert self.light().state == 'off'
assert self.other_light().state == 'off'

Expand All @@ -84,7 +85,6 @@ def test_on_brightness(self):

def test_on_off(self):
"""Test turning the light on and off."""

assert self.light().state == 'off'
assert self.other_light().state == 'off'

Expand All @@ -100,7 +100,6 @@ def test_on_off(self):

def test_activated_event(self):
"""Test handling an event from LiteJet."""

self.mock_lj.get_load_level.return_value = 99

# Light 1
Expand Down Expand Up @@ -138,7 +137,6 @@ def test_activated_event(self):

def test_deactivated_event(self):
"""Test handling an event from LiteJet."""

# Initial state is on.

self.mock_lj.get_load_level.return_value = 99
Expand Down
10 changes: 10 additions & 0 deletions tests/components/media_player/test_soundtouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ class MockDevice(STD):
"""Mock device."""

def __init__(self):
"""Init the class."""
self._config = MockConfig


class MockConfig(Config):
"""Mock config."""

def __init__(self):
"""Init class."""
self._name = "name"


Expand All @@ -49,6 +51,7 @@ class MockPreset(Preset):
"""Mock preset."""

def __init__(self, id):
"""Init the class."""
self._id = id
self._name = "preset"

Expand All @@ -57,13 +60,15 @@ class MockVolume(Volume):
"""Mock volume with value."""

def __init__(self):
"""Init class."""
self._actual = 12


class MockVolumeMuted(Volume):
"""Mock volume muted."""

def __init__(self):
"""Init the class."""
self._actual = 12
self._muted = True

Expand All @@ -72,13 +77,15 @@ class MockStatusStandby(Status):
"""Mock status standby."""

def __init__(self):
"""Init the class."""
self._source = "STANDBY"


class MockStatusPlaying(Status):
"""Mock status playing media."""

def __init__(self):
"""Init the class."""
self._source = ""
self._play_status = "PLAY_STATE"
self._image = "image.url"
Expand All @@ -93,6 +100,7 @@ class MockStatusPlayingRadio(Status):
"""Mock status radio."""

def __init__(self):
"""Init the class."""
self._source = ""
self._play_status = "PLAY_STATE"
self._image = "image.url"
Expand All @@ -107,6 +115,7 @@ class MockStatusUnknown(Status):
"""Mock status unknown media."""

def __init__(self):
"""Init the class."""
self._source = ""
self._play_status = "PLAY_STATE"
self._image = "image.url"
Expand All @@ -121,6 +130,7 @@ class MockStatusPause(Status):
"""Mock status pause."""

def __init__(self):
"""Init the class."""
self._source = ""
self._play_status = "PAUSE_STATE"

Expand Down
3 changes: 2 additions & 1 deletion tests/components/media_player/test_yamaha.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FakeYamaha(rxv.rxv.RXV):
ensure that usage of the rxv library by HomeAssistant is as we'd
expect.
"""

_fake_input = 'HDMI1'

def _discover_features(self):
Expand Down Expand Up @@ -75,7 +76,7 @@ def setUp(self):
self.rec = FakeYamaha('10.0.0.0')

def test_get_playback_support(self):
"""Test the playback"""
"""Test the playback."""
rec = self.rec
support = rec.get_playback_support()
self.assertFalse(support.play)
Expand Down
2 changes: 0 additions & 2 deletions tests/components/remote/test_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def tearDown(self):

def test_methods(self):
"""Test if methods call the services as expected."""

self.assertTrue(
setup_component(self.hass, remote.DOMAIN,
{remote.DOMAIN: {CONF_PLATFORM: 'demo'}}))
Expand All @@ -50,7 +49,6 @@ def test_methods(self):

def test_services(self):
"""Test the provided services."""

# Test turn_on
turn_on_calls = mock_service(
self.hass, remote.DOMAIN, SERVICE_TURN_ON)
Expand Down
8 changes: 4 additions & 4 deletions tests/components/remote/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def tearDown(self):
self.hass.stop()

def test_is_on(self):
""" Test is_on"""
"""Test is_on."""
self.hass.states.set('remote.test', STATE_ON)
self.assertTrue(remote.is_on(self.hass, 'remote.test'))

Expand All @@ -42,7 +42,7 @@ def test_is_on(self):
self.assertFalse(remote.is_on(self.hass))

def test_turn_on(self):
""" Test turn_on"""
"""Test turn_on."""
turn_on_calls = mock_service(
self.hass, remote.DOMAIN, SERVICE_TURN_ON)

Expand All @@ -58,7 +58,7 @@ def test_turn_on(self):
self.assertEqual(remote.DOMAIN, call.domain)

def test_turn_off(self):
""" Test turn_off"""
"""Test turn_off."""
turn_off_calls = mock_service(
self.hass, remote.DOMAIN, SERVICE_TURN_OFF)

Expand All @@ -75,7 +75,7 @@ def test_turn_off(self):
self.assertEqual('entity_id_val', call.data[ATTR_ENTITY_ID])

def test_send_command(self):
""" Test send_command"""
"""Test send_command."""
send_command_calls = mock_service(
self.hass, remote.DOMAIN, SERVICE_SEND_COMMAND)

Expand Down
3 changes: 2 additions & 1 deletion tests/components/scene/test_litejet.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ def teardown_method(self, method):
self.hass.stop()

def scene(self):
"""Get the current scene."""
return self.hass.states.get(ENTITY_SCENE)

def other_scene(self):
"""Get the other scene."""
return self.hass.states.get(ENTITY_OTHER_SCENE)

def test_activate(self):
"""Test activating the scene."""

scene.activate(self.hass, ENTITY_SCENE)
self.hass.block_till_done()
self.mock_lj.activate_scene.assert_called_once_with(
Expand Down
1 change: 1 addition & 0 deletions tests/components/sensor/test_api_streams.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test cases for the API stream sensor."""
import asyncio
import logging

Expand Down
Loading

0 comments on commit f0b1874

Please sign in to comment.