Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
LKuemmel committed Nov 14, 2023
1 parent b6ed3dc commit b11bc49
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import MagicMock, Mock
import pytest

from helpermodules import pub
from helpermodules import pub, timecheck


@pytest.fixture(autouse=True)
Expand All @@ -12,6 +12,8 @@ def mock_today(monkeypatch) -> None:
# Zeitzonen GitHub: UTC, Raspberry: Europe/Berlin
datetime_mock.today.return_value = datetime.datetime(2022, 5, 16, 8, 40, 52)
monkeypatch.setattr(datetime, "datetime", datetime_mock)
mock_today_timestamp = Mock(return_value=1652683252)
monkeypatch.setattr(timecheck, "create_timestamp", mock_today_timestamp)


@pytest.fixture(autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion packages/control/auto_phase_switch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(self,
expected_timestamp_auto_phase_switch=1652683252.0,
expected_state=ChargepointState.PHASE_SWITCH_DELAY),
Params("3to1, enough power, timer not expired", max_current_single_phase=16,
timestamp_auto_phase_switch="05/16/2022, 08:35:52", phases_to_use=3, required_current=6,
timestamp_auto_phase_switch=1652682952.0, phases_to_use=3, required_current=6,
evu_surplus=-860, reserved_evu_overhang=0, get_currents=[4.5, 4.4, 5.8],
get_power=3381, state=ChargepointState.PHASE_SWITCH_DELAY, expected_phases_to_use=3, expected_current=6,
expected_message=f"Umschaltverzögerung von 3 auf 1 Phasen abgebrochen{Ev.ENOUGH_POWER}",
Expand Down
4 changes: 2 additions & 2 deletions packages/helpermodules/timecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def check_timestamp(timestamp: int, duration: int) -> bool:
True: Zeit ist noch nicht abgelaufen
False: Zeit ist abgelaufen
"""
if (datetime.datetime.today().timestamp() - duration) > timestamp:
if (create_timestamp() - duration) > timestamp:
return False
else:
return True
Expand Down Expand Up @@ -277,4 +277,4 @@ def convert_timedelta_to_time_string(timedelta_obj: datetime.timedelta) -> str:


def get_difference_to_now(timestamp_begin: float) -> float:
return datetime.datetime.today().timestamp() - timestamp_begin
return create_timestamp() - timestamp_begin

0 comments on commit b11bc49

Please sign in to comment.