Skip to content

Commit

Permalink
test: timetravel and ensure state is unchanged
Browse files Browse the repository at this point in the history
  • Loading branch information
InTheDaylight14 committed Dec 22, 2022
1 parent 1fc3c4e commit d2d0918
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ async def test_time_charge_complete_charging(
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP
assert state.attributes.get(ATTR_STATE_CLASS) is None

mock_timetravel = mock_now + timedelta(minutes=2)
monkeypatch.setattr(dt, "utcnow", lambda: mock_timetravel)

state = hass.states.get("sensor.my_model_s_time_charge_complete")
charge_complete = mock_now + timedelta(
hours=float(car_mock_data.VEHICLE_DATA["charge_state"]["time_to_full_charge"])
)
charge_complete_str = datetime.strftime(charge_complete, "%Y-%m-%dT%H:%M:%S+00:00")


async def test_time_charge_completed(hass: HomeAssistant) -> None:
"""Tests time charge complete is the correct value."""
Expand Down

0 comments on commit d2d0918

Please sign in to comment.