Device tracker component & platform validation. No more home_range. (#2908)
* Device tracker component & platform validation. No more home_range. * Mock, bluetooth * Renamed _CONFIG_SCHEMA. Raise warning for #1606 * test duplicates * Fix assert * Coverage * Typing * T fixes
This commit is contained in:
parent
16e0187fcc
commit
55d305359e
10 changed files with 259 additions and 175 deletions
|
@ -1,5 +1,7 @@
|
|||
"""The tests for the MQTT device tracker platform."""
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
import logging
|
||||
import os
|
||||
|
||||
from homeassistant.bootstrap import _setup_component
|
||||
|
@ -9,6 +11,8 @@ from homeassistant.const import CONF_PLATFORM
|
|||
from tests.common import (
|
||||
get_test_home_assistant, mock_mqtt_component, fire_mqtt_message)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestComponentsDeviceTrackerMQTT(unittest.TestCase):
|
||||
"""Test MQTT device tracker platform."""
|
||||
|
@ -25,6 +29,27 @@ class TestComponentsDeviceTrackerMQTT(unittest.TestCase):
|
|||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
def test_ensure_device_tracker_platform_validation(self): \
|
||||
# pylint: disable=invalid-name
|
||||
"""Test if platform validation was done."""
|
||||
def mock_setup_scanner(hass, config, see):
|
||||
"""Check that Qos was added by validation."""
|
||||
self.assertTrue('qos' in config)
|
||||
|
||||
with patch('homeassistant.components.device_tracker.mqtt.'
|
||||
'setup_scanner', side_effect=mock_setup_scanner) as mock_sp:
|
||||
|
||||
dev_id = 'paulus'
|
||||
topic = '/location/paulus'
|
||||
self.hass.config.components = ['mqtt', 'zone']
|
||||
assert _setup_component(self.hass, device_tracker.DOMAIN, {
|
||||
device_tracker.DOMAIN: {
|
||||
CONF_PLATFORM: 'mqtt',
|
||||
'devices': {dev_id: topic}
|
||||
}
|
||||
})
|
||||
assert mock_sp.call_count == 1
|
||||
|
||||
def test_new_message(self):
|
||||
"""Test new message."""
|
||||
dev_id = 'paulus'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue