mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Move ee_brightbox imports at top-level (#29054)
* Move ee_brightbox imports at top-level * Fix tests * Fix : Commented out code
This commit is contained in:
parent
78d5184186
commit
44e708f72b
@ -1,6 +1,7 @@
|
|||||||
"""Support for EE Brightbox router."""
|
"""Support for EE Brightbox router."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from eebrightbox import EEBrightBox, EEBrightBoxException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.device_tracker import (
|
from homeassistant.components.device_tracker import (
|
||||||
@ -46,8 +47,6 @@ class EEBrightBoxScanner(DeviceScanner):
|
|||||||
|
|
||||||
def check_config(self):
|
def check_config(self):
|
||||||
"""Check if provided configuration and credentials are correct."""
|
"""Check if provided configuration and credentials are correct."""
|
||||||
from eebrightbox import EEBrightBox, EEBrightBoxException
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with EEBrightBox(self.config) as ee_brightbox:
|
with EEBrightBox(self.config) as ee_brightbox:
|
||||||
return bool(ee_brightbox.get_devices())
|
return bool(ee_brightbox.get_devices())
|
||||||
@ -57,8 +56,6 @@ class EEBrightBoxScanner(DeviceScanner):
|
|||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
"""Scan for devices."""
|
"""Scan for devices."""
|
||||||
from eebrightbox import EEBrightBox
|
|
||||||
|
|
||||||
with EEBrightBox(self.config) as ee_brightbox:
|
with EEBrightBox(self.config) as ee_brightbox:
|
||||||
self.devices = {d["mac"]: d for d in ee_brightbox.get_devices()}
|
self.devices = {d["mac"]: d for d in ee_brightbox.get_devices()}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from asynctest import patch
|
from asynctest import patch
|
||||||
|
from eebrightbox import EEBrightBoxException
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.device_tracker import DOMAIN
|
from homeassistant.components.device_tracker import DOMAIN
|
||||||
@ -41,8 +42,6 @@ def _configure_mock_get_devices(eebrightbox_mock):
|
|||||||
|
|
||||||
|
|
||||||
def _configure_mock_failed_config_check(eebrightbox_mock):
|
def _configure_mock_failed_config_check(eebrightbox_mock):
|
||||||
from eebrightbox import EEBrightBoxException
|
|
||||||
|
|
||||||
eebrightbox_instance = eebrightbox_mock.return_value
|
eebrightbox_instance = eebrightbox_mock.return_value
|
||||||
eebrightbox_instance.__enter__.side_effect = EEBrightBoxException(
|
eebrightbox_instance.__enter__.side_effect = EEBrightBoxException(
|
||||||
"Failed to connect to the router"
|
"Failed to connect to the router"
|
||||||
@ -55,7 +54,7 @@ def mock_dev_track(mock_device_tracker_conf):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@patch("eebrightbox.EEBrightBox")
|
@patch("homeassistant.components.ee_brightbox.device_tracker.EEBrightBox")
|
||||||
async def test_missing_credentials(eebrightbox_mock, hass):
|
async def test_missing_credentials(eebrightbox_mock, hass):
|
||||||
"""Test missing credentials."""
|
"""Test missing credentials."""
|
||||||
_configure_mock_get_devices(eebrightbox_mock)
|
_configure_mock_get_devices(eebrightbox_mock)
|
||||||
@ -73,7 +72,7 @@ async def test_missing_credentials(eebrightbox_mock, hass):
|
|||||||
assert hass.states.get("device_tracker.hostnameff") is None
|
assert hass.states.get("device_tracker.hostnameff") is None
|
||||||
|
|
||||||
|
|
||||||
@patch("eebrightbox.EEBrightBox")
|
@patch("homeassistant.components.ee_brightbox.device_tracker.EEBrightBox")
|
||||||
async def test_invalid_credentials(eebrightbox_mock, hass):
|
async def test_invalid_credentials(eebrightbox_mock, hass):
|
||||||
"""Test invalid credentials."""
|
"""Test invalid credentials."""
|
||||||
_configure_mock_failed_config_check(eebrightbox_mock)
|
_configure_mock_failed_config_check(eebrightbox_mock)
|
||||||
@ -93,7 +92,7 @@ async def test_invalid_credentials(eebrightbox_mock, hass):
|
|||||||
assert hass.states.get("device_tracker.hostnameff") is None
|
assert hass.states.get("device_tracker.hostnameff") is None
|
||||||
|
|
||||||
|
|
||||||
@patch("eebrightbox.EEBrightBox")
|
@patch("homeassistant.components.ee_brightbox.device_tracker.EEBrightBox")
|
||||||
async def test_get_devices(eebrightbox_mock, hass):
|
async def test_get_devices(eebrightbox_mock, hass):
|
||||||
"""Test valid configuration."""
|
"""Test valid configuration."""
|
||||||
_configure_mock_get_devices(eebrightbox_mock)
|
_configure_mock_get_devices(eebrightbox_mock)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user