Merge remote-tracking branch 'origin/main' into feat/meeting-1008
# Conflicts: # backend/services/sky_service.py
This commit is contained in:
commit
57cad25f32
7 files changed
+146
-64
No files matched your search
@@ -156,8 +156,8 @@ def test_score_rows_apply_air_at_sunset_and_keep_cloud_score_without_air():
|
||||
hourly = {("R", hour): SimpleNamespace(humidity=90, rain_prob=0)}
|
||||
om = {("R", sky_service._nearest_slot(hour)): SimpleNamespace(visibility_m=5000)}
|
||||
hazy = sky_service._score_rows(region, today, clouds, now, hourly, om)[0]["score"]
|
||||
assert hazy == round(plain * 0.6 * 0.75)
|
||||
rain = {("R", hour - timedelta(hours=3)): SimpleNamespace(humidity=50, rain_prob=80), ("R", hour): SimpleNamespace(humidity=50, rain_prob=10)}
|
||||
assert hazy == round(plain * 0.8 * 0.85)
|
||||
rain = {("R", hour - timedelta(hours=3)): SimpleNamespace(humidity=60, rain_prob=80), ("R", hour): SimpleNamespace(humidity=60, rain_prob=10)}
|
||||
assert sky_service._score_rows(region, today, clouds, now, rain, {})[0]["score"] == min(100, round(plain * 1.15))
|
||||
|
||||
|
||||
@@ -165,3 +165,30 @@ def test_nearest_slot_is_closest_three_hour_end():
|
||||
from datetime import datetime, timezone
|
||||
at = lambda h, m=0: datetime(2026, 10, 7, h, m, tzinfo=timezone.utc) # noqa: E731
|
||||
assert [sky_service._nearest_slot(at(h, m)).hour for h, m in ((8, 0), (9, 0), (10, 29), (10, 31))] == [9, 9, 9, 12]
|
||||
|
||||
|
||||
def test_open_west_bonus_applies_to_sunset_only_and_needs_a_spot_nearby():
|
||||
from datetime import date, datetime, timezone
|
||||
from types import SimpleNamespace
|
||||
|
||||
from common.enums import SkyType
|
||||
from services.calc.sky_score import Layers
|
||||
from services.calc.sun import sun_times
|
||||
|
||||
region = SimpleNamespace(code="R", lat=37.56, lon=126.91)
|
||||
today = date(2026, 10, 7)
|
||||
st = sun_times(today, region.lat, region.lon)
|
||||
clouds = {
|
||||
("R", kind.value, km, sky_service._nearest_hour(at), 3): Layers(0, 20, 0)
|
||||
for kind, at in ((SkyType.SUNSET, st.sunset_at), (SkyType.SUNRISE, st.sunrise_at)) for km in (20, 100)
|
||||
}
|
||||
now = datetime(2026, 10, 7, 3, tzinfo=timezone.utc)
|
||||
by = lambda rows: {(r["sky_type"], r["score_date"]): r["score"] for r in rows} # noqa: E731
|
||||
plain = by(sky_service._score_rows(region, today, clouds, now))
|
||||
west = by(sky_service._score_rows(region, today, clouds, now, open_west=True))
|
||||
assert west[(SkyType.SUNSET.value, today)] == min(100, round(plain[(SkyType.SUNSET.value, today)] * 1.1))
|
||||
assert west[(SkyType.SUNRISE.value, today)] == plain[(SkyType.SUNRISE.value, today)]
|
||||
|
||||
near = SimpleNamespace(lat=37.5555, lon=126.895) # 망원한강공원, 약 1.5km
|
||||
far = SimpleNamespace(lat=37.0, lon=126.0)
|
||||
assert sky_service._open_west(region, [near]) and not sky_service._open_west(region, [far]) and not sky_service._open_west(region, [])
|
||||
Reference in new issue
Block a user