mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Move imports to top for monoprice (#29516)
* Move imports to top for monoprice * Format test with black
This commit is contained in:
parent
98d2eadb76
commit
4e7b9eaed0
@ -1,9 +1,11 @@
|
||||
"""Support for interfacing with Monoprice 6 zone home audio controller."""
|
||||
import logging
|
||||
|
||||
from pymonoprice import get_monoprice
|
||||
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 (
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_TURN_OFF,
|
||||
@ -20,6 +22,7 @@ from homeassistant.const import (
|
||||
STATE_ON,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from .const import DOMAIN, SERVICE_RESTORE, SERVICE_SNAPSHOT
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -68,9 +71,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Monoprice 6-zone amplifier platform."""
|
||||
port = config.get(CONF_PORT)
|
||||
|
||||
from serial import SerialException
|
||||
from pymonoprice import get_monoprice
|
||||
|
||||
try:
|
||||
monoprice = get_monoprice(port)
|
||||
except SerialException:
|
||||
|
@ -174,7 +174,10 @@ class TestMonopriceMediaPlayer(unittest.TestCase):
|
||||
self.hass = tests.common.get_test_home_assistant()
|
||||
self.hass.start()
|
||||
# Note, source dictionary is unsorted!
|
||||
with mock.patch("pymonoprice.get_monoprice", new=lambda *a: self.monoprice):
|
||||
with mock.patch(
|
||||
"homeassistant.components.monoprice.media_player.get_monoprice",
|
||||
new=lambda *a: self.monoprice,
|
||||
):
|
||||
setup_platform(
|
||||
self.hass,
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user