Skip to content

Commit

Permalink
Consolidate more platforms (#22308)
Browse files Browse the repository at this point in the history
* Consolidate final platforms

* Fix some tests

* Fix more tests

* Fix more tests
  • Loading branch information
balloob authored Mar 24, 2019
1 parent 4c4eff1 commit 1ddc249
Show file tree
Hide file tree
Showing 45 changed files with 98 additions and 97 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/demo/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
https://home-assistant.io/components/demo/
"""
import datetime
from homeassistant.components.alarm_control_panel import manual
from homeassistant.components.manual.alarm_control_panel import ManualAlarm
from homeassistant.const import (
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_CUSTOM_BYPASS,
STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT,
Expand All @@ -17,7 +17,7 @@ async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the Demo alarm control panel platform."""
async_add_entities([
manual.ManualAlarm(hass, 'Alarm', '1234', None, False, {
ManualAlarm(hass, 'Alarm', '1234', None, False, {
STATE_ALARM_ARMED_AWAY: {
CONF_DELAY_TIME: datetime.timedelta(seconds=0),
CONF_PENDING_TIME: datetime.timedelta(seconds=5),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant.components.google import CONF_DEVICE_ID, CONF_NAME
import homeassistant.util.dt as dt_util

from . import CalendarEventDevice, get_date
from homeassistant.components.calendar import CalendarEventDevice, get_date


def setup_platform(hass, config, add_entities, discovery_info=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
import os

from . import SUPPORT_ON_OFF, Camera
from homeassistant.components.camera import SUPPORT_ON_OFF, Camera

_LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"""
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT

from . import ClimateDevice
from .const import (
from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, SUPPORT_AUX_HEAT,
SUPPORT_AWAY_MODE, SUPPORT_FAN_MODE, SUPPORT_HOLD_MODE, SUPPORT_ON_OFF,
SUPPORT_OPERATION_MODE, SUPPORT_SWING_MODE, SUPPORT_TARGET_HUMIDITY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from homeassistant.helpers.event import track_utc_time_change

from . import (
from homeassistant.components.cover import (
ATTR_POSITION, ATTR_TILT_POSITION, SUPPORT_CLOSE, SUPPORT_OPEN,
CoverDevice)

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from homeassistant.const import STATE_OFF

from . import (
from homeassistant.components.fan import (
SPEED_HIGH, SPEED_LOW, SPEED_MEDIUM, SUPPORT_DIRECTION, SUPPORT_OSCILLATE,
SUPPORT_SET_SPEED, FanEntity)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from homeassistant.helpers.event import track_time_interval

from . import GeolocationEvent
from homeassistant.components.geo_location import GeolocationEvent

_LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import random

from . import (
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_HS_COLOR,
ATTR_WHITE_VALUE, SUPPORT_BRIGHTNESS, SUPPORT_COLOR, SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT, SUPPORT_WHITE_VALUE, Light)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED

from . import SUPPORT_OPEN, LockDevice
from homeassistant.components.lock import SUPPORT_OPEN, LockDevice


def setup_platform(hass, config, add_entities, discovery_info=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING
import homeassistant.util.dt as dt_util

from . import MediaPlayerDevice
from .const import (
from homeassistant.components.media_player import MediaPlayerDevice
from homeassistant.components.media_player.const import (
MEDIA_TYPE_MOVIE, MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW,
SUPPORT_CLEAR_PLAYLIST, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PLAY,
SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK, SUPPORT_SELECT_SOUND_MODE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import logging

from . import (
from homeassistant.components.vacuum import (
ATTR_CLEANED_AREA, STATE_CLEANING, STATE_DOCKED, STATE_IDLE, STATE_PAUSED,
STATE_RETURNING, SUPPORT_BATTERY, SUPPORT_CLEAN_SPOT, SUPPORT_FAN_SPEED,
SUPPORT_LOCATE, SUPPORT_PAUSE, SUPPORT_RETURN_HOME, SUPPORT_SEND_COMMAND,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Demo platform that offers a fake water heater device."""
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT

from . import (
from homeassistant.components.water_heater import (
SUPPORT_AWAY_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE,
WaterHeaterDevice)

Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/generic_thermostat/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""The generic_thermostat component."""
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
async_track_state_change, async_track_time_interval)
from homeassistant.helpers.restore_state import RestoreEntity

from . import PLATFORM_SCHEMA, ClimateDevice
from .const import (
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateDevice
from homeassistant.components.climate.const import (
ATTR_AWAY_MODE, ATTR_OPERATION_MODE, STATE_AUTO, STATE_COOL, STATE_HEAT,
STATE_IDLE, SUPPORT_AWAY_MODE, SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_state_change

from . import (
from homeassistant.components.cover import (
ATTR_CURRENT_POSITION, ATTR_CURRENT_TILT_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, DOMAIN, PLATFORM_SCHEMA, SERVICE_CLOSE_COVER,
SERVICE_CLOSE_COVER_TILT, SERVICE_OPEN_COVER, SERVICE_OPEN_COVER_TILT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from homeassistant.helpers.event import async_track_state_change
from homeassistant.helpers.typing import ConfigType, HomeAssistantType

from . import (
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_EFFECT_LIST,
ATTR_FLASH, ATTR_HS_COLOR, ATTR_MAX_MIREDS, ATTR_MIN_MIREDS,
ATTR_TRANSITION, ATTR_WHITE_VALUE, PLATFORM_SCHEMA, SUPPORT_BRIGHTNESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from homeassistant.helpers.event import async_track_state_change
from homeassistant.helpers.typing import ConfigType, HomeAssistantType

from . import PLATFORM_SCHEMA, Light
from homeassistant.components.light import PLATFORM_SCHEMA, Light

_LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion script/gen_requirements_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def gather_modules():
if fnmatch.fnmatch(package, pattern):
break
else:
print("{}: {}".format(package, err))
print("{}: {}".format(package.replace('.', '/') + '.py', err))
errors.append(package)
continue

Expand Down
8 changes: 4 additions & 4 deletions tests/components/camera/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def mock_camera(hass):
}
}))

with patch('homeassistant.components.camera.demo.DemoCamera.camera_image',
with patch('homeassistant.components.demo.camera.DemoCamera.camera_image',
return_value=b'Test'):
yield

Expand Down Expand Up @@ -92,7 +92,7 @@ def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop()

@patch('homeassistant.components.camera.demo.DemoCamera.camera_image',
@patch('homeassistant.components.demo.camera.DemoCamera.camera_image',
autospec=True, return_value=b'Test')
def test_get_image_from_camera(self, mock_camera):
"""Grab an image from camera entity."""
Expand Down Expand Up @@ -199,7 +199,7 @@ async def test_webocket_camera_stream(hass, hass_ws_client, hass_client,
with patch('homeassistant.components.camera.request_stream',
return_value='http://home.assistant/playlist.m3u8'
) as mock_request_stream, \
patch('homeassistant.components.camera.demo.DemoCamera.stream_source',
patch('homeassistant.components.demo.camera.DemoCamera.stream_source',
new_callable=PropertyMock) as mock_stream_source:
mock_stream_source.return_value = generate_h264_video()
# Request playlist through WebSocket
Expand Down Expand Up @@ -241,7 +241,7 @@ async def test_handle_play_stream_service(hass, mock_camera, mock_stream):
}
with patch('homeassistant.components.camera.request_stream'
) as mock_request_stream, \
patch('homeassistant.components.camera.demo.DemoCamera.stream_source',
patch('homeassistant.components.demo.camera.DemoCamera.stream_source',
new_callable=PropertyMock) as mock_stream_source:
mock_stream_source.return_value = generate_h264_video()
# Call service
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def test_init_state_is_streaming(hass, demo_camera):
assert demo_camera.state == STATE_STREAMING

mock_on_img = mock_open(read_data=b'ON')
with patch('homeassistant.components.camera.demo.open', mock_on_img,
with patch('homeassistant.components.demo.camera.open', mock_on_img,
create=True):
image = await camera.async_get_image(hass, demo_camera.entity_id)
assert mock_on_img.called
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest.mock import patch

from homeassistant.components import geo_location
from homeassistant.components.geo_location.demo import \
from homeassistant.components.demo.geo_location import \
NUMBER_OF_DEMO_DEVICES, DEFAULT_UNIT_OF_MEASUREMENT, \
DEFAULT_UPDATE_INTERVAL
from homeassistant.setup import setup_component
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def test_prev_next_track(self):
state = self.hass.states.get(ent_id)
assert 1 == state.attributes.get('media_episode')

@patch('homeassistant.components.media_player.demo.DemoYoutubePlayer.'
@patch('homeassistant.components.demo.media_player.DemoYoutubePlayer.'
'media_seek', autospec=True)
def test_play_media(self, mock_seek):
"""Test play_media ."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
SERVICE_SEND_COMMAND, SERVICE_SET_FAN_SPEED,
STATE_DOCKED, STATE_CLEANING, STATE_PAUSED, STATE_IDLE,
STATE_RETURNING)
from homeassistant.components.vacuum.demo import (
from homeassistant.components.demo.vacuum import (
DEMO_VACUUM_BASIC, DEMO_VACUUM_COMPLETE, DEMO_VACUUM_MINIMAL,
DEMO_VACUUM_MOST, DEMO_VACUUM_NONE, DEMO_VACUUM_STATE, FAN_SPEEDS)
from homeassistant.const import (
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/components/facebox/test_image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def mock_isfile():
@pytest.fixture
def mock_image():
"""Return a mock camera image."""
with patch('homeassistant.components.camera.demo.DemoCamera.camera_image',
with patch('homeassistant.components.demo.camera.DemoCamera.camera_image',
return_value=b'Test') as image:
yield image

Expand Down
2 changes: 1 addition & 1 deletion tests/components/google_assistant/test_smart_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from homeassistant.components.google_assistant import (
const, trait, helpers, smart_home as sh,
EVENT_COMMAND_RECEIVED, EVENT_QUERY_RECEIVED, EVENT_SYNC_RECEIVED)
from homeassistant.components.light.demo import DemoLight
from homeassistant.components.demo.light import DemoLight

from homeassistant.helpers import device_registry
from tests.common import (mock_device_registry, mock_registry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from homeassistant.components.cover import (
ATTR_CURRENT_POSITION, ATTR_CURRENT_TILT_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, DOMAIN)
from homeassistant.components.cover.group import DEFAULT_NAME
from homeassistant.components.group.cover import DEFAULT_NAME
from homeassistant.const import (
ATTR_ASSUMED_STATE, ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME,
ATTR_SUPPORTED_FEATURES, CONF_ENTITIES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import asynctest

from homeassistant.components.light import group
import homeassistant.components.group.light as group
from homeassistant.setup import async_setup_component

from tests.components.light import common
Expand Down
2 changes: 1 addition & 1 deletion tests/components/image_processing/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop()

@patch('homeassistant.components.camera.demo.DemoCamera.camera_image',
@patch('homeassistant.components.demo.camera.DemoCamera.camera_image',
autospec=True, return_value=b'Test')
def test_get_image_from_camera(self, mock_camera):
"""Grab an image from camera entity."""
Expand Down
Loading

0 comments on commit 1ddc249

Please sign in to comment.