def test_has_battery(monkeypatch):
    """Test has_battery()."""

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

    _data = _mock.data_request_vehicle()
    _switch = SentryModeSwitch(_data, _controller)

    assert not _switch.has_battery()
def test_available_false(monkeypatch):
    """Test available() when flag sentry_mode_available is false."""

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

    _data = _mock.data_request_vehicle()
    _data["vehicle_state"]["sentry_mode_available"] = False
    _switch = SentryModeSwitch(_data, _controller)

    assert not _switch.available()
def test_is_on_true(monkeypatch):
    """Test is_on() when flag sentry_mode is true."""

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

    _data = _mock.data_request_vehicle()
    _data["vehicle_state"]["sentry_mode_available"] = True
    _data["vehicle_state"]["sentry_mode"] = True
    _switch = SentryModeSwitch(_data, _controller)

    assert _switch.is_on()
async def test_enable_sentry_mode(monkeypatch):
    """Test enable_sentry_mode()."""

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

    _data = _mock.data_request_vehicle()
    _data["vehicle_state"]["sentry_mode_available"] = True
    _data["vehicle_state"]["sentry_mode"] = False
    _switch = SentryModeSwitch(_data, _controller)

    await _switch.enable_sentry_mode()
    assert _switch.is_on()
예제 #5
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)
async def test_async_update_with_change_same_value(monkeypatch):
    """Test async_update() with a state change, using same value."""

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

    _data = _mock.data_request_vehicle()
    _data["vehicle_state"]["sentry_mode_available"] = True
    _data["vehicle_state"]["sentry_mode"] = True
    _switch = SentryModeSwitch(_data, _controller)

    # Change state value
    _data["vehicle_state"]["sentry_mode"] = True

    await _switch.async_update()
    assert _switch.is_on()
예제 #7
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))