Move blackbird imports (#27849)

* Move imports in blackbird component

* fixed tests after import move to top level
This commit is contained in:
bouni 2019-10-18 15:12:36 +02:00 committed by Pascal Vizeli
parent c0d084fb04
commit 3bb46d5080
2 changed files with 7 additions and 5 deletions

View file

@ -2,9 +2,11 @@
import logging
import socket
from pyblackbird import get_blackbird
from serial import SerialException
import voluptuous as vol
from homeassistant.components.media_player import MediaPlayerDevice, PLATFORM_SCHEMA
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerDevice
from homeassistant.components.media_player.const import (
DOMAIN,
SUPPORT_SELECT_SOURCE,
@ -72,9 +74,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
port = config.get(CONF_PORT)
host = config.get(CONF_HOST)
from pyblackbird import get_blackbird
from serial import SerialException
connection = None
if port is not None:
try:

View file

@ -180,7 +180,10 @@ class TestBlackbirdMediaPlayer(unittest.TestCase):
self.hass = tests.common.get_test_home_assistant()
self.hass.start()
# Note, source dictionary is unsorted!
with mock.patch("pyblackbird.get_blackbird", new=lambda *a: self.blackbird):
with mock.patch(
"homeassistant.components.blackbird.media_player.get_blackbird",
new=lambda *a: self.blackbird,
):
setup_platform(
self.hass,
{