Storage entity registry (#16018)

* Split out storage delayed write

* Update code using delayed save

* Fix tests

* Fix typing test

* Add callback decorator

* Migrate entity registry to storage helper

* Make double loading protection easier

* Lint

* Fix tests

* Ordered Dict
This commit is contained in:
Paulus Schoutsen authored and Pascal Vizeli committed 2018-08-18 13:34:33 +02:00
1 parent ef193b0f64
commit 8ec550d6e0
7 files changed
+167 -149

No files matched your search

+11 -9
View File
@@ -14,7 +14,7 @@ from homeassistant.components import light
from homeassistant.helpers.intent import IntentHandleError
from tests.common import (
async_mock_service, mock_service, get_test_home_assistant)
async_mock_service, mock_service, get_test_home_assistant, mock_storage)
class TestLight(unittest.TestCase):
@@ -333,10 +333,11 @@ class TestLight(unittest.TestCase):
"group.all_lights.default,.4,.6,99\n"
with mock.patch('os.path.isfile', side_effect=_mock_isfile):
with mock.patch('builtins.open', side_effect=_mock_open):
self.assertTrue(setup_component(
self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}
))
with mock_storage():
self.assertTrue(setup_component(
self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}
))
dev, _, _ = platform.DEVICES
light.turn_on(self.hass, dev.entity_id)
@@ -371,10 +372,11 @@ class TestLight(unittest.TestCase):
"light.ceiling_2.default,.6,.6,100\n"
with mock.patch('os.path.isfile', side_effect=_mock_isfile):
with mock.patch('builtins.open', side_effect=_mock_open):
self.assertTrue(setup_component(
self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}
))
with mock_storage():
self.assertTrue(setup_component(
self.hass, light.DOMAIN,
{light.DOMAIN: {CONF_PLATFORM: 'test'}}
))
dev = next(filter(lambda x: x.entity_id == 'light.ceiling_2',
platform.DEVICES))