Ejemplo n.º 1
0
async def test_state(opp):
    """Test state."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        await thermostat.async_update()
        assert thermostat.state == HVAC_MODE_HEAT

        thermostat._cur_settings = None
        assert thermostat.state is None
Ejemplo n.º 2
0
async def test_melissa_op_to_opp(opp):
    """Test for translate melissa operations to opp."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert thermostat.melissa_op_to_opp(1) == HVAC_MODE_FAN_ONLY
        assert thermostat.melissa_op_to_opp(2) == HVAC_MODE_HEAT
        assert thermostat.melissa_op_to_opp(3) == HVAC_MODE_COOL
        assert thermostat.melissa_op_to_opp(4) == HVAC_MODE_DRY
        assert thermostat.melissa_op_to_opp(5) is None
Ejemplo n.º 3
0
async def test_target_temperature(opp):
    """Test target temperature."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        await thermostat.async_update()
        assert thermostat.target_temperature == 16

        thermostat._cur_settings = None
        assert thermostat.target_temperature is None
Ejemplo n.º 4
0
async def test_melissa_fan_to_opp(opp):
    """Test for translate melissa fan state to opp."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert thermostat.melissa_fan_to_opp(0) == "auto"
        assert thermostat.melissa_fan_to_opp(1) == SPEED_LOW
        assert thermostat.melissa_fan_to_opp(2) == SPEED_MEDIUM
        assert thermostat.melissa_fan_to_opp(3) == SPEED_HIGH
        assert thermostat.melissa_fan_to_opp(4) is None
Ejemplo n.º 5
0
async def test_get_name(opp):
    """Test name property."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert thermostat.name == "Melissa 12345678"
Ejemplo n.º 6
0
async def test_max_temp(opp):
    """Test max temp."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert thermostat.max_temp == 30
Ejemplo n.º 7
0
async def test_temperature_unit(opp):
    """Test temperature unit."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert thermostat.temperature_unit == TEMP_CELSIUS
Ejemplo n.º 8
0
async def test_current_temperature(opp):
    """Test current temperature."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert thermostat.current_temperature == 27.4
Ejemplo n.º 9
0
async def test_send(opp):
    """Test send."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        await thermostat.async_update()
        await opp.async_block_till_done()
        await thermostat.async_send({"fan": api.FAN_MEDIUM})
        await opp.async_block_till_done()
        assert thermostat.fan_mode == SPEED_MEDIUM
        api.async_send.return_value = AsyncMock(return_value=False)
        thermostat._cur_settings = None
        await thermostat.async_send({"fan": api.FAN_LOW})
        await opp.async_block_till_done()
        assert SPEED_LOW != thermostat.fan_mode
        assert thermostat._cur_settings is None
Ejemplo n.º 10
0
async def test_fan_modes(opp):
    """Test the fan list."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert ["auto", SPEED_HIGH, SPEED_MEDIUM,
                SPEED_LOW] == thermostat.fan_modes
Ejemplo n.º 11
0
async def test_supported_features(opp):
    """Test supported_features property."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE
        assert thermostat.supported_features == features
Ejemplo n.º 12
0
async def test_set_temperature(opp):
    """Test set_temperature."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        await thermostat.async_update()
        await thermostat.async_set_temperature(**{ATTR_TEMPERATURE: 25})
        assert thermostat.target_temperature == 25
Ejemplo n.º 13
0
async def test_fan_mode(opp):
    """Test set_fan_mode."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        await thermostat.async_update()
        await opp.async_block_till_done()
        await thermostat.async_set_fan_mode(SPEED_HIGH)
        await opp.async_block_till_done()
        assert thermostat.fan_mode == SPEED_HIGH
Ejemplo n.º 14
0
async def test_set_operation_mode(opp):
    """Test set_operation_mode."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        await thermostat.async_update()
        await opp.async_block_till_done()
        await thermostat.async_set_hvac_mode(HVAC_MODE_COOL)
        await opp.async_block_till_done()
        assert thermostat.hvac_mode == HVAC_MODE_COOL
Ejemplo n.º 15
0
async def test_opp_fan_to_melissa(opp):
    """Test for translate melissa states to opp."""
    with patch("openpeerpower.components.melissa.climate._LOGGER.warning"
               ) as mocked_warning, patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert thermostat.opp_fan_to_melissa("auto") == 0
        assert thermostat.opp_fan_to_melissa(SPEED_LOW) == 1
        assert thermostat.opp_fan_to_melissa(SPEED_MEDIUM) == 2
        assert thermostat.opp_fan_to_melissa(SPEED_HIGH) == 3
        thermostat.opp_fan_to_melissa("test")
        mocked_warning.assert_called_once_with(
            "Melissa have no setting for %s fan mode", "test")
Ejemplo n.º 16
0
async def test_operation_list(opp):
    """Test the operation list."""
    with patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert [
            HVAC_MODE_HEAT,
            HVAC_MODE_COOL,
            HVAC_MODE_DRY,
            HVAC_MODE_FAN_ONLY,
            HVAC_MODE_OFF,
        ] == thermostat.hvac_modes
Ejemplo n.º 17
0
async def test_update(opp):
    """Test update."""
    with patch("openpeerpower.components.melissa.climate._LOGGER.warning"
               ) as mocked_warning, patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        await thermostat.async_update()
        assert thermostat.fan_mode == SPEED_LOW
        assert thermostat.state == HVAC_MODE_HEAT
        api.async_status = AsyncMock(side_effect=KeyError("boom"))
        await thermostat.async_update()
        mocked_warning.assert_called_once_with("Unable to update entity %s",
                                               thermostat.entity_id)
Ejemplo n.º 18
0
async def test_opp_mode_to_melissa(opp):
    """Test for opp.operations to melssa."""
    with patch("openpeerpower.components.melissa.climate._LOGGER.warning"
               ) as mocked_warning, patch("openpeerpower.components.melissa"):
        api = melissa_mock()
        device = (await api.async_fetch_devices())[_SERIAL]
        thermostat = MelissaClimate(api, _SERIAL, device)
        assert thermostat.opp_mode_to_melissa(HVAC_MODE_FAN_ONLY) == 1
        assert thermostat.opp_mode_to_melissa(HVAC_MODE_HEAT) == 2
        assert thermostat.opp_mode_to_melissa(HVAC_MODE_COOL) == 3
        assert thermostat.opp_mode_to_melissa(HVAC_MODE_DRY) == 4
        thermostat.opp_mode_to_melissa("test")
        mocked_warning.assert_called_once_with(
            "Melissa have no setting for %s mode", "test")