Fix bt_home_hub_5 device tracker (#15096)

* Fix bt_home_hub_5 device tracker

Updated BT Home Hub 5 device tracker component to get it working again. The old parsing method of the DNS table has been broken for a while causing the component to fail to get connected devices. A new parsing method has been implemened and fixes all previous issues.

* Moved part of code to a published PyPi library

* Fixed Violations

* Fixed bugs in device tracker

* Moved API Specific Code to PyPi Repository

* Updated to fit requested changes, removed test as it is no longer valid and updated requirement_all.txt

* Update to fit style requirements and remove redundant code

* Removed Unnecessary Comment
This commit is contained in:
ahobsonsayers 2018-08-06 06:38:02 +01:00 committed by Martin Hjelmare
parent ac4674fdb0
commit e4b2ae29bd
3 changed files with 21 additions and 120 deletions

View file

@ -1,53 +0,0 @@
"""The tests for the BT Home Hub 5 device tracker platform."""
import unittest
from unittest.mock import patch
from homeassistant.components.device_tracker import bt_home_hub_5
from homeassistant.const import CONF_HOST
patch_file = 'homeassistant.components.device_tracker.bt_home_hub_5'
def _get_homehub_data(url):
"""Return mock homehub data."""
return '''
[
{
"mac": "AA:BB:CC:DD:EE:FF,
"hostname": "hostname",
"ip": "192.168.1.43",
"ipv6": "",
"name": "hostname",
"activity": "1",
"os": "Unknown",
"device": "Unknown",
"time_first_seen": "2016/06/05 11:14:45",
"time_last_active": "2016/06/06 11:33:08",
"dhcp_option": "39043T90430T9TGK0EKGE5KGE3K904390K45GK054",
"port": "wl0",
"ipv6_ll": "fe80::gd67:ghrr:fuud:4332",
"activity_ip": "1",
"activity_ipv6_ll": "0",
"activity_ipv6": "0",
"device_oui": "NA",
"device_serial": "NA",
"device_class": "NA"
}
]
'''
class TestBTHomeHub5DeviceTracker(unittest.TestCase):
"""Test BT Home Hub 5 device tracker platform."""
@patch('{}._get_homehub_data'.format(patch_file), new=_get_homehub_data)
def test_config_minimal(self):
"""Test the setup with minimal configuration."""
config = {
'device_tracker': {
CONF_HOST: 'foo'
}
}
result = bt_home_hub_5.get_scanner(None, config)
self.assertIsNotNone(result)