known devices yaml robustness (#2523)
This commit is contained in:
parent
e38b7d97d2
commit
ef64e11b50
2 changed files with 23 additions and 6 deletions
|
@ -4,6 +4,7 @@ import unittest
|
|||
from unittest.mock import patch
|
||||
from datetime import datetime, timedelta
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from homeassistant.loader import get_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
@ -45,6 +46,18 @@ class TestComponentsDeviceTracker(unittest.TestCase):
|
|||
|
||||
self.assertFalse(device_tracker.is_on(self.hass, entity_id))
|
||||
|
||||
def test_reading_broken_yaml_config(self):
|
||||
"""Test when known devices contains invalid data."""
|
||||
with tempfile.NamedTemporaryFile() as fp:
|
||||
# file is empty
|
||||
assert device_tracker.load_config(fp.name, None, False, 0) == []
|
||||
|
||||
fp.write('100'.encode('utf-8'))
|
||||
fp.flush()
|
||||
|
||||
# file contains a non-dict format
|
||||
assert device_tracker.load_config(fp.name, None, False, 0) == []
|
||||
|
||||
def test_reading_yaml_config(self):
|
||||
"""Test the rendering of the YAML configuration."""
|
||||
dev_id = 'test'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue