1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Don't write storage to disk while stopping (#33456)

* Don't write storage to disk while stopping

* rework change

* lint

* remove delay save and schedule final write at stop

* update tests

* fix test component using private methods

* cleanup

* always listen

* use stop in restore state again

* whitelist JSON exceptions for later

* review comment

* make zwave tests use mock storage
This commit is contained in:
David F. Mulcahey
2020-04-02 13:25:28 -04:00
committed by GitHub
parent 9fd0192441
commit 8b0a0ee521
8 changed files with 147 additions and 34 deletions

View File

@@ -28,6 +28,7 @@ from tests.common import (
get_test_home_assistant,
mock_coro,
mock_registry,
mock_storage,
)
from tests.mock.zwave import MockEntityValues, MockNetwork, MockNode, MockValue
@@ -827,6 +828,8 @@ class TestZWaveDeviceEntityValues(unittest.TestCase):
def setUp(self):
"""Initialize values for this testcase class."""
self.hass = get_test_home_assistant()
self.mock_storage = mock_storage()
self.mock_storage.__enter__()
self.hass.start()
self.registry = mock_registry(self.hass)
@@ -862,6 +865,7 @@ class TestZWaveDeviceEntityValues(unittest.TestCase):
def tearDown(self): # pylint: disable=invalid-name
"""Stop everything that was started."""
self.hass.stop()
self.mock_storage.__exit__(None, None, None)
@patch.object(zwave, "import_module")
@patch.object(zwave, "discovery")
@@ -1194,6 +1198,8 @@ class TestZWaveServices(unittest.TestCase):
def setUp(self):
"""Initialize values for this testcase class."""
self.hass = get_test_home_assistant()
self.mock_storage = mock_storage()
self.mock_storage.__enter__()
self.hass.start()
# Initialize zwave
@@ -1209,6 +1215,7 @@ class TestZWaveServices(unittest.TestCase):
self.hass.services.call("zwave", "stop_network", {})
self.hass.block_till_done()
self.hass.stop()
self.mock_storage.__exit__(None, None, None)
def test_add_node(self):
"""Test zwave add_node service."""