API POST has new state validation (fix for state = 0) (#8324)
* Fix validation of get new state * Add unittest to check posting a state with zero value
This commit is contained in:
1 parent
f4a97db783
commit
58de661ad5
2 files changed
+18
-1
No files matched your search
@@ -96,6 +96,23 @@ def test_api_state_change_with_bad_data(hass, mock_api_client):
|
||||
assert resp.status == 400
|
||||
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
@asyncio.coroutine
|
||||
def test_api_state_change_to_zero_value(hass, mock_api_client):
|
||||
"""Test if changing a state to a zero value is possible."""
|
||||
resp = yield from mock_api_client.post(
|
||||
const.URL_API_STATES_ENTITY.format("test_entity.with_zero_state"),
|
||||
json={'state': 0})
|
||||
|
||||
assert resp.status == 201
|
||||
|
||||
resp = yield from mock_api_client.post(
|
||||
const.URL_API_STATES_ENTITY.format("test_entity.with_zero_state"),
|
||||
json={'state': 0.})
|
||||
|
||||
assert resp.status == 200
|
||||
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
@asyncio.coroutine
|
||||
def test_api_state_change_push(hass, mock_api_client):
|
||||
|
||||
Reference in new issue
Block a user