Zwave save cache to file now. (#10381)

* Add save config

* Add API to save Z-Wave cache to file immediatley.

* lint

* remove none assignment

* docstring
This commit is contained in:
John Arild Berentsen authored and GitHub committed 2017-11-06 15:15:52 +01:00
1 parent 131af1fece
commit 5410700708
2 files changed
+58 -3

No files matched your search

+34 -1
View File
@@ -9,7 +9,7 @@ from homeassistant.components import config
from homeassistant.components.zwave import DATA_NETWORK, const
from homeassistant.components.config.zwave import (
ZWaveNodeValueView, ZWaveNodeGroupView, ZWaveNodeConfigView,
ZWaveUserCodeView)
ZWaveUserCodeView, ZWaveConfigWriteView)
from tests.common import mock_http_component_app
from tests.mock.zwave import MockNode, MockValue, MockEntityValues
@@ -417,3 +417,36 @@ def test_get_usercodes_no_genreuser(hass, test_client):
result = yield from resp.json()
assert result == {}
@asyncio.coroutine
def test_save_config_no_network(hass, test_client):
"""Test saving configuration without network data."""
app = mock_http_component_app(hass)
ZWaveConfigWriteView().register(app.router)
client = yield from test_client(app)
resp = yield from client.post('/api/zwave/saveconfig')
assert resp.status == 404
result = yield from resp.json()
assert result == {'message': 'No Z-Wave network data found'}
@asyncio.coroutine
def test_save_config(hass, test_client):
"""Test saving configuration."""
app = mock_http_component_app(hass)
ZWaveConfigWriteView().register(app.router)
network = hass.data[DATA_NETWORK] = MagicMock()
client = yield from test_client(app)
resp = yield from client.post('/api/zwave/saveconfig')
assert resp.status == 200
result = yield from resp.json()
assert network.write_config.called
assert result == {'message': 'Z-Wave configuration saved to file.'}