Improve boolean validator (#24294)

* Improve boolean validator

* Remove extra throw

* Remove None test as discussed

* Fix for tests depending on None == False
This commit is contained in:
Penny Wood authored and Paulus Schoutsen committed 2019-06-07 22:18:02 -07:00
1 parent 233bc1a108
commit b30f4b8fc0
5 files changed
+20 -9

No files matched your search

+4 -2
View File
@@ -203,7 +203,8 @@ class TestDemoClimate(unittest.TestCase):
"""Test setting the away mode without required attribute."""
state = self.hass.states.get(ENTITY_CLIMATE)
assert 'on' == state.attributes.get('away_mode')
common.set_away_mode(self.hass, None, ENTITY_CLIMATE)
with pytest.raises(vol.Invalid):
common.set_away_mode(self.hass, None, ENTITY_CLIMATE)
self.hass.block_till_done()
assert 'on' == state.attributes.get('away_mode')
@@ -246,7 +247,8 @@ class TestDemoClimate(unittest.TestCase):
"""Test setting the auxiliary heater without required attribute."""
state = self.hass.states.get(ENTITY_CLIMATE)
assert 'off' == state.attributes.get('aux_heat')
common.set_aux_heat(self.hass, None, ENTITY_CLIMATE)
with pytest.raises(vol.Invalid):
common.set_aux_heat(self.hass, None, ENTITY_CLIMATE)
self.hass.block_till_done()
assert 'off' == state.attributes.get('aux_heat')
+2 -1
View File
@@ -90,7 +90,8 @@ class TestDemoMediaPlayer(unittest.TestCase):
assert False is state.attributes.get('is_volume_muted')
common.mute_volume(self.hass, None, entity_id)
with pytest.raises(vol.Invalid):
common.mute_volume(self.hass, None, entity_id)
self.hass.block_till_done()
state = self.hass.states.get(entity_id)
assert False is state.attributes.get('is_volume_muted')
+2 -1
View File
@@ -95,7 +95,8 @@ class TestDemowater_heater(unittest.TestCase):
"""Test setting the away mode without required attribute."""
state = self.hass.states.get(ENTITY_WATER_HEATER)
assert 'off' == state.attributes.get('away_mode')
common.set_away_mode(self.hass, None, ENTITY_WATER_HEATER)
with pytest.raises(vol.Invalid):
common.set_away_mode(self.hass, None, ENTITY_WATER_HEATER)
self.hass.block_till_done()
assert 'off' == state.attributes.get('away_mode')