Convert some test helpers to coroutines and adjust tests (#23352)
* Convert some test helpers to coroutines * Fix tests
This commit is contained in:
1 parent
86b017e2f0
commit
5376e15286
24 files changed
+498
-991
No files matched your search
@@ -29,12 +29,10 @@ async def test_turn_on(hass):
|
||||
"""Test turning on the device."""
|
||||
assert STATE_OFF == get_entity(hass).state
|
||||
|
||||
common.async_turn_on(hass, FAN_ENTITY_ID)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_on(hass, FAN_ENTITY_ID)
|
||||
assert STATE_OFF != get_entity(hass).state
|
||||
|
||||
common.async_turn_on(hass, FAN_ENTITY_ID, fan.SPEED_HIGH)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_on(hass, FAN_ENTITY_ID, fan.SPEED_HIGH)
|
||||
assert STATE_ON == get_entity(hass).state
|
||||
assert fan.SPEED_HIGH == \
|
||||
get_entity(hass).attributes[fan.ATTR_SPEED]
|
||||
@@ -44,12 +42,10 @@ async def test_turn_off(hass):
|
||||
"""Test turning off the device."""
|
||||
assert STATE_OFF == get_entity(hass).state
|
||||
|
||||
common.async_turn_on(hass, FAN_ENTITY_ID)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_on(hass, FAN_ENTITY_ID)
|
||||
assert STATE_OFF != get_entity(hass).state
|
||||
|
||||
common.async_turn_off(hass, FAN_ENTITY_ID)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_off(hass, FAN_ENTITY_ID)
|
||||
assert STATE_OFF == get_entity(hass).state
|
||||
|
||||
|
||||
@@ -57,12 +53,10 @@ async def test_turn_off_without_entity_id(hass):
|
||||
"""Test turning off all fans."""
|
||||
assert STATE_OFF == get_entity(hass).state
|
||||
|
||||
common.async_turn_on(hass, FAN_ENTITY_ID)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_on(hass, FAN_ENTITY_ID)
|
||||
assert STATE_OFF != get_entity(hass).state
|
||||
|
||||
common.async_turn_off(hass)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_off(hass)
|
||||
assert STATE_OFF == get_entity(hass).state
|
||||
|
||||
|
||||
@@ -70,8 +64,8 @@ async def test_set_direction(hass):
|
||||
"""Test setting the direction of the device."""
|
||||
assert STATE_OFF == get_entity(hass).state
|
||||
|
||||
common.async_set_direction(hass, FAN_ENTITY_ID, fan.DIRECTION_REVERSE)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_set_direction(hass, FAN_ENTITY_ID,
|
||||
fan.DIRECTION_REVERSE)
|
||||
assert fan.DIRECTION_REVERSE == \
|
||||
get_entity(hass).attributes.get('direction')
|
||||
|
||||
@@ -80,8 +74,7 @@ async def test_set_speed(hass):
|
||||
"""Test setting the speed of the device."""
|
||||
assert STATE_OFF == get_entity(hass).state
|
||||
|
||||
common.async_set_speed(hass, FAN_ENTITY_ID, fan.SPEED_LOW)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_set_speed(hass, FAN_ENTITY_ID, fan.SPEED_LOW)
|
||||
assert fan.SPEED_LOW == \
|
||||
get_entity(hass).attributes.get('speed')
|
||||
|
||||
@@ -90,12 +83,10 @@ async def test_oscillate(hass):
|
||||
"""Test oscillating the fan."""
|
||||
assert not get_entity(hass).attributes.get('oscillating')
|
||||
|
||||
common.async_oscillate(hass, FAN_ENTITY_ID, True)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_oscillate(hass, FAN_ENTITY_ID, True)
|
||||
assert get_entity(hass).attributes.get('oscillating')
|
||||
|
||||
common.async_oscillate(hass, FAN_ENTITY_ID, False)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_oscillate(hass, FAN_ENTITY_ID, False)
|
||||
assert not get_entity(hass).attributes.get('oscillating')
|
||||
|
||||
|
||||
@@ -103,6 +94,5 @@ async def test_is_on(hass):
|
||||
"""Test is on service call."""
|
||||
assert not fan.is_on(hass, FAN_ENTITY_ID)
|
||||
|
||||
common.async_turn_on(hass, FAN_ENTITY_ID)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_on(hass, FAN_ENTITY_ID)
|
||||
assert fan.is_on(hass, FAN_ENTITY_ID)
|
||||
@@ -20,32 +20,30 @@ def setup_comp(hass):
|
||||
|
||||
async def test_state_attributes(hass):
|
||||
"""Test light state attributes."""
|
||||
common.async_turn_on(
|
||||
await common.async_turn_on(
|
||||
hass, ENTITY_LIGHT, xy_color=(.4, .4), brightness=25)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(ENTITY_LIGHT)
|
||||
assert light.is_on(hass, ENTITY_LIGHT)
|
||||
assert (0.4, 0.4) == state.attributes.get(light.ATTR_XY_COLOR)
|
||||
assert 25 == state.attributes.get(light.ATTR_BRIGHTNESS)
|
||||
assert (255, 234, 164) == state.attributes.get(light.ATTR_RGB_COLOR)
|
||||
assert 'rainbow' == state.attributes.get(light.ATTR_EFFECT)
|
||||
common.async_turn_on(
|
||||
await common.async_turn_on(
|
||||
hass, ENTITY_LIGHT, rgb_color=(251, 253, 255),
|
||||
white_value=254)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(ENTITY_LIGHT)
|
||||
assert 254 == state.attributes.get(light.ATTR_WHITE_VALUE)
|
||||
assert (250, 252, 255) == state.attributes.get(light.ATTR_RGB_COLOR)
|
||||
assert (0.319, 0.326) == state.attributes.get(light.ATTR_XY_COLOR)
|
||||
common.async_turn_on(hass, ENTITY_LIGHT, color_temp=400, effect='none')
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_on(
|
||||
hass, ENTITY_LIGHT, color_temp=400, effect='none')
|
||||
state = hass.states.get(ENTITY_LIGHT)
|
||||
assert 400 == state.attributes.get(light.ATTR_COLOR_TEMP)
|
||||
assert 153 == state.attributes.get(light.ATTR_MIN_MIREDS)
|
||||
assert 500 == state.attributes.get(light.ATTR_MAX_MIREDS)
|
||||
assert 'none' == state.attributes.get(light.ATTR_EFFECT)
|
||||
common.async_turn_on(hass, ENTITY_LIGHT, kelvin=3000, brightness_pct=50)
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_on(
|
||||
hass, ENTITY_LIGHT, kelvin=3000, brightness_pct=50)
|
||||
state = hass.states.get(ENTITY_LIGHT)
|
||||
assert 333 == state.attributes.get(light.ATTR_COLOR_TEMP)
|
||||
assert 127 == state.attributes.get(light.ATTR_BRIGHTNESS)
|
||||
|
||||
Reference in new issue
Block a user