Week ahead in the weather strip, reverse LCD at night
The weekday strip now shows today and the next six days (icon, max, min), the current temperature and feels-like sit next to the clock, and the rain graph spans the full width with the hour under every bar. From sunset to sunrise the whole frame, seconds patch included, is drawn as a reverse LCD. The rain label is now spelled DÉŠŤ. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
45508b1b68
commit
6c9a1420d2
10 files changed
+341
-122
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import copy
|
||||
import json
|
||||
from datetime import datetime
|
||||
from datetime import date, datetime
|
||||
from pathlib import Path
|
||||
|
||||
import weather_data
|
||||
from weather_data import Icon, icon_for, parse_weather
|
||||
from weather_data import Day, Icon, icon_for, parse_weather
|
||||
|
||||
FIXTURE = json.loads((Path(__file__).parent / "fixtures" / "open-meteo-zlin.json").read_text())
|
||||
NOW = datetime(2026, 10, 22, 12, 45)
|
||||
@@ -24,9 +24,34 @@ def test_parse_fixture_window():
|
||||
assert (w.temp, w.code) == (10.2, 61)
|
||||
|
||||
|
||||
def test_parse_today_max_min():
|
||||
def test_parse_week_with_sunrise_and_sunset():
|
||||
w = parse_weather(payload(), NOW)
|
||||
assert (w.today_max, w.today_min) == (15.0, 6.0)
|
||||
assert len(w.days) == 7
|
||||
assert w.days[0] == Day(date(2026, 10, 22), 63, 15.0, 6.0,
|
||||
datetime(2026, 10, 22, 7, 20), datetime(2026, 10, 22, 17, 45))
|
||||
assert w.days[6] == Day(date(2026, 10, 28), 45, 11.5, -0.5,
|
||||
datetime(2026, 10, 28, 6, 30), datetime(2026, 10, 28, 16, 35))
|
||||
|
||||
|
||||
def test_parse_feels_like():
|
||||
assert parse_weather(payload(), NOW).feels == 8.1
|
||||
|
||||
|
||||
def test_null_day_entries_become_none():
|
||||
p = payload()
|
||||
p["daily"]["weather_code"][1] = None
|
||||
p["daily"]["sunset"][1] = None
|
||||
day = parse_weather(p, NOW).days[1]
|
||||
assert (day.code, day.sunset) == (None, None)
|
||||
assert day.sunrise == datetime(2026, 10, 23, 7, 22)
|
||||
|
||||
|
||||
def test_short_daily_lists_give_none_not_errors():
|
||||
p = payload()
|
||||
p["daily"]["temperature_2m_min"] = p["daily"]["temperature_2m_min"][:3]
|
||||
w = parse_weather(p, NOW)
|
||||
assert len(w.days) == 7
|
||||
assert (w.days[2].low, w.days[3].low) == (4.3, None)
|
||||
|
||||
|
||||
def test_window_runs_into_tomorrow_late_in_the_day():
|
||||
@@ -74,7 +99,7 @@ def test_missing_current_gives_none_temp():
|
||||
|
||||
def test_missing_sections_do_not_raise():
|
||||
w = parse_weather({}, NOW)
|
||||
assert (w.temp, w.today_max, w.hours) == (None, None, ())
|
||||
assert (w.temp, w.feels, w.days, w.hours) == (None, None, (), ())
|
||||
|
||||
|
||||
def test_fetch_passes_coordinates():
|
||||
@@ -99,3 +124,25 @@ def test_fetch_passes_coordinates():
|
||||
assert params["timezone"] == "Europe/Prague"
|
||||
assert timeout == 10
|
||||
assert len(w.hours) == 12
|
||||
assert len(w.days) == 7
|
||||
|
||||
|
||||
def test_fetch_asks_for_a_week_with_sun_times_and_feels_like():
|
||||
seen = {}
|
||||
|
||||
class Response:
|
||||
def raise_for_status(self):
|
||||
pass
|
||||
|
||||
def json(self):
|
||||
return payload()
|
||||
|
||||
def fake_get(url, params=None, timeout=None):
|
||||
seen.update(params)
|
||||
return Response()
|
||||
|
||||
weather_data.fetch_weather(NOW, get=fake_get)
|
||||
assert seen["forecast_days"] >= 7
|
||||
assert set(seen["daily"].split(",")) >= {"weather_code", "temperature_2m_max", "temperature_2m_min",
|
||||
"sunrise", "sunset"}
|
||||
assert "apparent_temperature" in seen["current"].split(",")
|
||||
Reference in new issue
Block a user