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

+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