mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Use API to discover Hue if no bridges specified (#11909)
* Use API to discover Hue if no bridges specified * hide config file
This commit is contained in:
committed by
Pascal Vizeli
parent
9123dfce6d
commit
3d9ff372fc
@@ -1,12 +1,12 @@
|
||||
"""Generic Philips Hue component tests."""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import unittest
|
||||
from unittest.mock import call, MagicMock, patch
|
||||
|
||||
from homeassistant.components import configurator, hue
|
||||
from homeassistant.const import CONF_FILENAME, CONF_HOST
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
|
||||
from tests.common import (
|
||||
assert_setup_component, get_test_home_assistant, get_test_config_dir,
|
||||
@@ -38,15 +38,6 @@ class TestSetup(unittest.TestCase):
|
||||
mock_phue.Bridge.assert_not_called()
|
||||
self.assertEquals({}, self.hass.data[hue.DOMAIN])
|
||||
|
||||
@MockDependency('phue')
|
||||
def test_setup_no_host(self, mock_phue):
|
||||
"""No host specified in any way."""
|
||||
with assert_setup_component(1):
|
||||
self.assertTrue(setup_component(
|
||||
self.hass, hue.DOMAIN, {hue.DOMAIN: {}}))
|
||||
mock_phue.Bridge.assert_not_called()
|
||||
self.assertEquals({}, self.hass.data[hue.DOMAIN])
|
||||
|
||||
@MockDependency('phue')
|
||||
def test_setup_with_host(self, mock_phue):
|
||||
"""Host specified in the config file."""
|
||||
@@ -400,3 +391,17 @@ class TestHueBridge(unittest.TestCase):
|
||||
{hue.ATTR_GROUP_NAME: 'group', hue.ATTR_SCENE_NAME: 'scene'},
|
||||
blocking=True)
|
||||
bridge.bridge.run_scene.assert_called_once_with('group', 'scene')
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_setup_no_host(hass, requests_mock):
|
||||
"""No host specified in any way."""
|
||||
requests_mock.get(hue.API_NUPNP, json=[])
|
||||
with MockDependency('phue') as mock_phue:
|
||||
result = yield from async_setup_component(
|
||||
hass, hue.DOMAIN, {hue.DOMAIN: {}})
|
||||
assert result
|
||||
|
||||
mock_phue.Bridge.assert_not_called()
|
||||
|
||||
assert hass.data[hue.DOMAIN] == {}
|
||||
|
||||
Reference in New Issue
Block a user