Beispiel #1
0
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()
    assert fan.is_on(hass, FAN_ENTITY_ID)
Beispiel #2
0
async def test_set_direction(hass, calls):
    """Test set valid direction."""
    await _register_components(hass)

    # Turn on fan
    common.async_turn_on(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # Set fan's direction to forward
    common.async_set_direction(hass, _TEST_FAN, DIRECTION_FORWARD)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_DIRECTION_INPUT_SELECT).state \
        == DIRECTION_FORWARD
    _verify(hass, STATE_ON, None, None, DIRECTION_FORWARD)

    # Set fan's direction to reverse
    common.async_set_direction(hass, _TEST_FAN, DIRECTION_REVERSE)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_DIRECTION_INPUT_SELECT).state \
        == DIRECTION_REVERSE
    _verify(hass, STATE_ON, None, None, DIRECTION_REVERSE)
Beispiel #3
0
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()
    assert fan.is_on(hass, FAN_ENTITY_ID)
Beispiel #4
0
async def test_set_invalid_direction(hass, calls):
    """Test set invalid direction when fan has valid direction."""
    await _register_components(hass)

    # Turn on fan
    common.async_turn_on(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # Set fan's direction to forward
    common.async_set_direction(hass, _TEST_FAN, DIRECTION_FORWARD)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_DIRECTION_INPUT_SELECT).state == \
        DIRECTION_FORWARD
    _verify(hass, STATE_ON, None, None, DIRECTION_FORWARD)

    # Set fan's direction to 'invalid'
    common.async_set_direction(hass, _TEST_FAN, 'invalid')
    await hass.async_block_till_done()

    # verify direction is unchanged
    assert hass.states.get(_DIRECTION_INPUT_SELECT).state == \
        DIRECTION_FORWARD
    _verify(hass, STATE_ON, None, None, DIRECTION_FORWARD)
Beispiel #5
0
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()
    assert STATE_OFF != get_entity(hass).state

    common.async_turn_off(hass)
    await hass.async_block_till_done()
    assert STATE_OFF == get_entity(hass).state
Beispiel #6
0
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()
    assert STATE_OFF != get_entity(hass).state

    common.async_turn_off(hass, FAN_ENTITY_ID)
    await hass.async_block_till_done()
    assert STATE_OFF == get_entity(hass).state
Beispiel #7
0
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()
    assert STATE_OFF != get_entity(hass).state

    common.async_turn_off(hass, FAN_ENTITY_ID)
    await hass.async_block_till_done()
    assert STATE_OFF == get_entity(hass).state
Beispiel #8
0
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()
    assert STATE_OFF != get_entity(hass).state

    common.async_turn_off(hass)
    await hass.async_block_till_done()
    assert STATE_OFF == get_entity(hass).state
Beispiel #9
0
async def test_on_with_speed(hass, calls):
    """Test turn on with speed."""
    await _register_components(hass)

    # Turn on fan with high speed
    common.async_turn_on(hass, _TEST_FAN, SPEED_HIGH)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_STATE_INPUT_BOOLEAN).state == STATE_ON
    assert hass.states.get(_SPEED_INPUT_SELECT).state == SPEED_HIGH
    _verify(hass, STATE_ON, SPEED_HIGH, None, None)
Beispiel #10
0
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()
    assert STATE_OFF != get_entity(hass).state

    common.async_turn_on(hass, FAN_ENTITY_ID, fan.SPEED_HIGH)
    await hass.async_block_till_done()
    assert STATE_ON == get_entity(hass).state
    assert fan.SPEED_HIGH == \
        get_entity(hass).attributes[fan.ATTR_SPEED]
Beispiel #11
0
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()
    assert STATE_OFF != get_entity(hass).state

    common.async_turn_on(hass, FAN_ENTITY_ID, fan.SPEED_HIGH)
    await hass.async_block_till_done()
    assert STATE_ON == get_entity(hass).state
    assert fan.SPEED_HIGH == \
        get_entity(hass).attributes[fan.ATTR_SPEED]
Beispiel #12
0
async def test_set_invalid_direction_from_initial_stage(hass, calls):
    """Test set invalid direction when fan is in initial state."""
    await _register_components(hass)

    # Turn on fan
    common.async_turn_on(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # Set fan's direction to 'invalid'
    common.async_set_direction(hass, _TEST_FAN, 'invalid')
    await hass.async_block_till_done()

    # verify direction is unchanged
    assert hass.states.get(_DIRECTION_INPUT_SELECT).state == ''
    _verify(hass, STATE_ON, None, None, None)
Beispiel #13
0
async def test_set_invalid_osc_from_initial_state(hass, calls):
    """Test set invalid oscillating when fan is in initial state."""
    await _register_components(hass)

    # Turn on fan
    common.async_turn_on(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # Set fan's osc to 'invalid'
    common.async_oscillate(hass, _TEST_FAN, 'invalid')
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_OSC_INPUT).state == ''
    _verify(hass, STATE_ON, None, None, None)
Beispiel #14
0
async def test_on_off(hass, calls):
    """Test turn on and turn off."""
    await _register_components(hass)

    # Turn on fan
    common.async_turn_on(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_STATE_INPUT_BOOLEAN).state == STATE_ON
    _verify(hass, STATE_ON, None, None, None)

    # Turn off fan
    common.async_turn_off(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_STATE_INPUT_BOOLEAN).state == STATE_OFF
    _verify(hass, STATE_OFF, None, None, None)
Beispiel #15
0
async def test_set_speed(hass, calls):
    """Test set valid speed."""
    await _register_components(hass)

    # Turn on fan
    common.async_turn_on(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # Set fan's speed to high
    common.async_set_speed(hass, _TEST_FAN, SPEED_HIGH)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_SPEED_INPUT_SELECT).state == SPEED_HIGH
    _verify(hass, STATE_ON, SPEED_HIGH, None, None)

    # Set fan's speed to medium
    common.async_set_speed(hass, _TEST_FAN, SPEED_MEDIUM)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_SPEED_INPUT_SELECT).state == SPEED_MEDIUM
    _verify(hass, STATE_ON, SPEED_MEDIUM, None, None)
Beispiel #16
0
async def test_set_invalid_speed(hass, calls):
    """Test set invalid speed when fan has valid speed."""
    await _register_components(hass)

    # Turn on fan
    common.async_turn_on(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # Set fan's speed to high
    common.async_set_speed(hass, _TEST_FAN, SPEED_HIGH)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_SPEED_INPUT_SELECT).state == SPEED_HIGH
    _verify(hass, STATE_ON, SPEED_HIGH, None, None)

    # Set fan's speed to 'invalid'
    common.async_set_speed(hass, _TEST_FAN, 'invalid')
    await hass.async_block_till_done()

    # verify speed is unchanged
    assert hass.states.get(_SPEED_INPUT_SELECT).state == SPEED_HIGH
    _verify(hass, STATE_ON, SPEED_HIGH, None, None)
Beispiel #17
0
async def test_custom_speed_list(hass, calls):
    """Test set custom speed list."""
    await _register_components(hass, ['1', '2', '3'])

    # Turn on fan
    common.async_turn_on(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # Set fan's speed to '1'
    common.async_set_speed(hass, _TEST_FAN, '1')
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_SPEED_INPUT_SELECT).state == '1'
    _verify(hass, STATE_ON, '1', None, None)

    # Set fan's speed to 'medium' which is invalid
    common.async_set_speed(hass, _TEST_FAN, SPEED_MEDIUM)
    await hass.async_block_till_done()

    # verify that speed is unchanged
    assert hass.states.get(_SPEED_INPUT_SELECT).state == '1'
    _verify(hass, STATE_ON, '1', None, None)
Beispiel #18
0
async def test_set_invalid_osc(hass, calls):
    """Test set invalid oscillating when fan has valid osc."""
    await _register_components(hass)

    # Turn on fan
    common.async_turn_on(hass, _TEST_FAN)
    await hass.async_block_till_done()

    # Set fan's osc to True
    common.async_oscillate(hass, _TEST_FAN, True)
    await hass.async_block_till_done()

    # verify
    assert hass.states.get(_OSC_INPUT).state == 'True'
    _verify(hass, STATE_ON, None, True, None)

    # Set fan's osc to False
    common.async_oscillate(hass, _TEST_FAN, None)
    await hass.async_block_till_done()

    # verify osc is unchanged
    assert hass.states.get(_OSC_INPUT).state == 'True'
    _verify(hass, STATE_ON, None, True, None)