Ejemplo n.º 1
0
def test_has_battery(monkeypatch):
    """Test has_battery()."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _climate = Climate(_data, _controller)

    assert not _climate.has_battery()
Ejemplo n.º 2
0
async def test_get_fan_status(monkeypatch):
    """Test get_fan_status()."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _data["climate_state"]["fan_status"] = 1
    _climate = Climate(_data, _controller)

    await _climate.async_update()

    assert not _climate.get_fan_status() is None
    assert _climate.get_fan_status() == 1
Ejemplo n.º 3
0
async def test_get_current_temp(monkeypatch):
    """Test get_current_temp()."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _data["climate_state"]["inside_temp"] = 18.8
    _climate = Climate(_data, _controller)

    await _climate.async_update()

    assert not _climate.get_current_temp() is None
    assert _climate.get_current_temp() == 18.8
Ejemplo n.º 4
0
async def test_set_status_off(monkeypatch):
    """Test set_status() to disabled."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _climate = Climate(_data, _controller)

    await _climate.async_update()
    await _climate.set_status(False)

    assert not _climate.is_hvac_enabled() is None
    assert not _climate.is_hvac_enabled()
Ejemplo n.º 5
0
async def test_is_hvac_enabled_off(monkeypatch):
    """Test is_hvac_enabled() when is_climate_on is False."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _data["climate_state"]["is_climate_on"] = False
    _climate = Climate(_data, _controller)

    await _climate.async_update()

    assert not _climate.is_hvac_enabled() is None
    assert not _climate.is_hvac_enabled()
Ejemplo n.º 6
0
async def test_get_goal_temp(monkeypatch):
    """Test get_goal_temp()."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _data["climate_state"]["driver_temp_setting"] = 23.4
    _climate = Climate(_data, _controller)

    await _climate.async_update()

    assert not _climate.get_goal_temp() is None
    assert _climate.get_goal_temp() == 23.4
Ejemplo n.º 7
0
async def test_set_temperature(monkeypatch):
    """Test set_temperature()."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _climate = Climate(_data, _controller)

    await _climate.async_update()

    await _climate.set_temperature(12.3)

    assert not _climate.get_goal_temp() is None
    assert _climate.get_goal_temp() == 12.3
Ejemplo n.º 8
0
 def _add_components(self, car):
     self.__components.append(Climate(car, self))
     self.__components.append(Battery(car, self))
     self.__components.append(Range(car, self))
     self.__components.append(TempSensor(car, self))
     self.__components.append(Lock(car, self))
     self.__components.append(ChargerLock(car, self))
     self.__components.append(ChargerConnectionSensor(car, self))
     self.__components.append(ChargingSensor(car, self))
     self.__components.append(ChargerSwitch(car, self))
     self.__components.append(RangeSwitch(car, self))
     self.__components.append(ParkingSensor(car, self))
     self.__components.append(GPS(car, self))
     self.__components.append(Odometer(car, self))
     self.__components.append(OnlineSensor(car, self))
     self.__components.append(SentryModeSwitch(car, self))
     self.__components.append(TrunkLock(car, self))
     self.__components.append(FrunkLock(car, self))
     self.__components.append(UpdateSensor(car, self))
     for seat in [
             "left", "right", "rear_left", "rear_center", "rear_right"
     ]:
         try:
             self.__components.append(HeatedSeatSwitch(car, self, seat))
         except KeyError:
             _LOGGER.debug("Seat warmer %s not detected", seat)
Ejemplo n.º 9
0
async def test_set_preset_mode_invalid_modes(monkeypatch):
    """Test set_preset_mode() with invalid modes."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _climate = Climate(_data, _controller)

    await _climate.async_update()

    bad_modes = ["UKNOWN_MODE", "home", "auto", "away", "hot"]
    for mode in bad_modes:
        assert mode not in _climate.preset_modes
        with pytest.raises(UnknownPresetMode):
            await _climate.set_preset_mode(mode)
Ejemplo n.º 10
0
async def test_set_preset_mode_success(monkeypatch):
    """Test set_preset_mode()."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _climate = Climate(_data, _controller)

    await _climate.async_update()

    preset_modes = _climate.preset_modes
    for mode in preset_modes:
        await _climate.set_preset_mode(mode)
        assert _climate.preset_mode is not None
        assert _climate.preset_mode == mode
Ejemplo n.º 11
0
 def _add_components(self, car):
     self.__components.append(Climate(car, self))
     self.__components.append(Battery(car, self))
     self.__components.append(Range(car, self))
     self.__components.append(TempSensor(car, self))
     self.__components.append(Lock(car, self))
     self.__components.append(ChargerLock(car, self))
     self.__components.append(ChargerConnectionSensor(car, self))
     self.__components.append(ChargingSensor(car, self))
     self.__components.append(ChargerSwitch(car, self))
     self.__components.append(RangeSwitch(car, self))
     self.__components.append(ParkingSensor(car, self))
     self.__components.append(GPS(car, self))
     self.__components.append(Odometer(car, self))
     self.__components.append(OnlineSensor(car, self))
     self.__components.append(SentryModeSwitch(car, self))
     self.__components.append(TrunkLock(car, self))
     self.__components.append(FrunkLock(car, self))
     self.__components.append(UpdateSensor(car, self))
Ejemplo n.º 12
0
async def test_get_values_after_update(monkeypatch):
    """Test values after an update."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _climate = Climate(_data, _controller)

    await _climate.async_update()

    assert _climate is not None

    assert _climate.get_current_temp() is None
    assert not _climate.get_fan_status() is None
    assert _climate.get_fan_status() == 0
    assert not _climate.get_goal_temp() is None
    assert _climate.get_goal_temp() == 21.6
    assert not _climate.is_hvac_enabled() is None
    assert not _climate.is_hvac_enabled()
    assert _climate.preset_mode is not None
    assert _climate.preset_mode == "normal"
Ejemplo n.º 13
0
def test_get_values_on_init(monkeypatch):
    """Test values after initialization."""

    _mock = TeslaMock(monkeypatch)
    _controller = Controller(None)

    _data = _mock.data_request_vehicle()
    _climate = Climate(_data, _controller)

    assert _climate is not None
    assert _climate.get_current_temp() is None
    assert _climate.get_fan_status() is None
    assert _climate.get_goal_temp() is None
    assert _climate.is_hvac_enabled() is None
    assert _climate.preset_mode is None