blob: 2a646320f966188d939b327ba5d7347090b0f43f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import json
from datetime import timezone
from zoneinfo import ZoneInfo
from hyprsunset_qt.sun import to_local_hm, read_cache, write_cache
def test_utc_to_local_hm():
# 2026-07-17T17:40:00+00:00 -> 19:40 in Europe/Rome (UTC+2 summer)
tz = ZoneInfo("Europe/Rome")
assert to_local_hm("2026-07-17T17:40:00+00:00", tz) == "19:40"
def test_cache_roundtrip(tmp_path):
path = tmp_path / "sun.json"
payload = {"lat": "45.07", "lon": "7.68", "results": {"sunset": "x"}}
write_cache(payload, path)
assert read_cache(path) == payload
def test_read_cache_missing(tmp_path):
assert read_cache(tmp_path / "nope.json") is None
|