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

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

    _data = _mock.data_request_vehicle()
    _seat = HeatedSeatSwitch(_data, _controller, 'left')

    assert not _seat.has_battery()
Ejemplo n.º 2
0
def test_get_seat_heat_level_on_init(monkeypatch):
    """Test get_seat_heat_level() after initialization."""

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

    _data = _mock.data_request_vehicle()
    _seat = HeatedSeatSwitch(_data, _controller, 'left')

    assert not _seat is None
    assert _seat.get_seat_heat_level() == 3 # 3 is mocked initial level for left seat from tesla_mock.py
Ejemplo n.º 3
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.º 4
0
async def test_get_seat_heat_level_after_update(monkeypatch):
    """Test get_seat_heat_level() after an update."""

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

    NEW_LEVEL = 1

    _data = _mock.data_request_vehicle()
    _data["climate_state"]['seat_heater_left'] = NEW_LEVEL
    _seat = HeatedSeatSwitch(_data, _controller, 'left')

    await _seat.async_update()

    assert not _seat is None
    assert _seat.get_seat_heat_level() == NEW_LEVEL
Ejemplo n.º 5
0
async def test_seat_same_level(monkeypatch):
    """Test set_seat_heat_level to same level."""

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

    ORIG_LEVEL = 1

    _data = _mock.data_request_vehicle()
    _data["climate_state"]["seat_heater_left"] = ORIG_LEVEL
    _seat = HeatedSeatSwitch(_data, _controller, 'left')

    await _seat.async_update()

    await _seat.set_seat_heat_level(ORIG_LEVEL)

    assert not _seat is None
    assert _seat.get_seat_heat_level() == ORIG_LEVEL
Ejemplo n.º 6
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))
     self.__components.append(HeatedSeatSwitch(car, self, 'left'))
     self.__components.append(HeatedSeatSwitch(car, self, 'right'))
     self.__components.append(HeatedSeatSwitch(car, self, 'rear_left'))
     self.__components.append(HeatedSeatSwitch(car, self, 'rear_center'))
     self.__components.append(HeatedSeatSwitch(car, self, 'rear_right'))