diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-17 10:22:40 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-17 10:22:40 +0200 |
| commit | 1b949b536dee4039625218ed7de0634a94e7fa86 (patch) | |
| tree | 9b19d8caf365dc6d0d97b08bf989b58bc2d6a03d /tests | |
| parent | fa74bf36bd5cce6e86c9f38f71284d8d429cc5d6 (diff) | |
| download | hyprsunset-qt-1b949b536dee4039625218ed7de0634a94e7fa86.tar.gz hyprsunset-qt-1b949b536dee4039625218ed7de0634a94e7fa86.zip | |
feat: sun UTC-to-local conversion and cache
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_sun.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_sun.py b/tests/test_sun.py new file mode 100644 index 0000000..2a64632 --- /dev/null +++ b/tests/test_sun.py @@ -0,0 +1,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 |
