def test_set_system_time_now(monkeypatch) -> None: # GIVEN subpr_mock = mock.Mock() monkeypatch.setattr("ovshell_core.gpstime.subprocess", subpr_mock) newtime = datetime(2003, 5, 29, 1, 1, 1) # WHEN, THEN assert gpstime.set_system_time(newtime) == True subpr_mock.run.assert_called_with( ["date", "+%F %H:%M:%S", "-s", "2003-05-29 01:01:01"], check=True)
def test_set_system_time_tolerable_offset() -> None: newtime = datetime(2020, 5, 29, 1, 1, 2) now = datetime(2020, 5, 29, 1, 1, 1) assert gpstime.set_system_time(newtime, now) == False