feat: 밤 구간(21~06시) Open-Meteo 햇빛 값(일조·일사·자외선) 저장 제외, 지수 계산은 0으로 처리

This commit is contained in:
skkim committed 2026-10-07 10:07:59 +09:00
1 parent 1a1df4bb87
commit 9dacc86f47
6 files changed
+50 -9

No files matched your search

+14
View File
@@ -134,6 +134,20 @@ def test_windows_attach_instant_values_from_nearest_slot_and_sunshine_from_cover
assert all(h.uv is None and h.sunshine_ratio is None for h in no_om)
def test_dark_slots_count_as_no_sun_not_unknown():
day = date(2026, 10, 6)
start = kst_midnight(day)
by_at = {
start + timedelta(hours=h): WeatherHourly(
forecast_at=start + timedelta(hours=h), feels_c=20, rain_type=1, rain_prob=0, wind_ms=1.0, humidity=50, sky=1
)
for h in (22, 23)
}
by_om = {start + timedelta(hours=24): OpenMeteoHourly(forecast_at=start + timedelta(hours=24), uv_index=None, sunshine_s=None, visibility_m=20000)}
hours = windows_for(SimpleNamespace(windows=[{"from": 22, "to": 24}]), day, None, by_at, by_om)[0]
assert [(h.uv, h.sunshine_ratio, h.visibility_km) for h in hours] == [(0.0, 0.0, 20.0)] * 2
@pytest.mark.anyio
async def test_new_axis_shows_only_for_weighted_indices_and_unknown_without_data(fakes):
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
+12
View File
@@ -48,6 +48,18 @@ def test_missing_hour_value_makes_aggregate_none_but_keeps_instant_values():
assert rows[6]["sunshine_s"] == 9000
def test_dark_slots_drop_sun_values_but_keep_others():
times = [f"2026-10-06T{h:02d}:00" for h in range(24)]
full = {k: [1.0] * 24 for k in ("uv_index", "uv_index_clear_sky", "visibility", "wind_gusts_10m", "pressure_msl", "soil_temperature_0cm")}
rows = {r["forecast_at"].hour: r for r in parse_weather({"hourly": {"time": times, "sunshine_duration": [600] * 24, "shortwave_radiation": [50] * 24} | full})}
dark = {15, 18, 21} # GMT 끝 시각 = KST 0·3·6시 (21~06시). KST 21시 구간(18~21시)은 남긴다
assert sorted(rows) == [3, 6, 9, 12, 15, 18, 21]
for hour, row in rows.items():
sun = (row["uv_index"], row["uv_index_clear_sky"], row["sunshine_s"], row["shortwave_avg_wm2"], row["shortwave_max_wm2"])
assert (sun == (None,) * 5) is (hour in dark)
assert row["visibility_m"] == 1 and row["soil_temp_c"] == 1.0
@pytest.mark.anyio
async def test_refresh_stores_every_region_and_is_repeatable(offline):
assert await jobs.refresh_openmeteo_weather() is ErrorType.SUCCESS