mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-05-06 02:48:38 +00:00

* Add new time handling * migrate date for python3.9 * add timedate * add tests & simplify it * better testing * use ssl * use hostname with new interface * expose to API * update data * add base handler * new timezone handling * improve handling * Improve handling * Add tests * Time adjustment function * Fix logging * tweak condition * don't adjust synchronized time * Guard * ignore UTC * small cleanup * like that, we can leaf it * add URL * add comment * Apply suggestions from code review Co-authored-by: Joakim Sørensen <joasoe@gmail.com> Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""Test TimeDate dbus interface."""
|
|
from datetime import datetime, timezone
|
|
|
|
import pytest
|
|
|
|
from supervisor.coresys import CoreSys
|
|
from supervisor.exceptions import DBusNotConnectedError
|
|
|
|
|
|
async def test_dbus_timezone(coresys: CoreSys):
|
|
"""Test coresys dbus connection."""
|
|
assert coresys.dbus.timedate.dt_utc is None
|
|
|
|
await coresys.dbus.timedate.connect()
|
|
await coresys.dbus.timedate.update()
|
|
|
|
assert coresys.dbus.timedate.dt_utc == datetime(
|
|
2021, 5, 19, 8, 36, 54, 405718, tzinfo=timezone.utc
|
|
)
|
|
|
|
assert (
|
|
coresys.dbus.timedate.dt_utc.isoformat() == "2021-05-19T08:36:54.405718+00:00"
|
|
)
|
|
|
|
|
|
async def test_dbus_settime(coresys: CoreSys):
|
|
"""Set timestamp on backend."""
|
|
test_dt = datetime(2021, 5, 19, 8, 36, 54, 405718, tzinfo=timezone.utc)
|
|
|
|
with pytest.raises(DBusNotConnectedError):
|
|
await coresys.dbus.timedate.set_time(test_dt)
|
|
|
|
await coresys.dbus.timedate.connect()
|
|
|
|
await coresys.dbus.timedate.set_time(test_dt)
|
|
|
|
|
|
async def test_dbus_setntp(coresys: CoreSys):
|
|
"""Disable NTP on backend."""
|
|
with pytest.raises(DBusNotConnectedError):
|
|
await coresys.dbus.timedate.set_ntp(False)
|
|
|
|
await coresys.dbus.timedate.connect()
|
|
|
|
await coresys.dbus.timedate.set_ntp(False)
|