feat: 10/6 회의 반영 — 각 점수 하향, 주말 카드 매일·다음 주말, 일반구를 시로 합침
- 각 점수: 편한 범위 안에서도 최적값에서만 100, 가장 나쁜 요인이 전체를 끌어내림 - 피드 노을 시간대 각 정렬 오류 수정 - 주말 카드 매일 노출, 예보가 닿으면 다음 주말 슬라이드 추가, 주말·행사 탭 열흘 - 지역 256→230 (일반구 39개를 시 13개로) - 회의 기록과 TODO.md 추가
This commit is contained in:
1 parent
a9ddbaab3c
commit
14ddebd040
12 files changed
+156
-76
No files matched your search
@@ -1,4 +1,4 @@
|
||||
from datetime import date
|
||||
from datetime import date, timedelta
|
||||
|
||||
import pytest
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
@@ -20,16 +20,23 @@ async def _posts(day: date):
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_build_day_adds_weekend_post_only_from_thursday():
|
||||
async def test_build_day_adds_weekend_post_every_day():
|
||||
monday, thursday = date(2026, 10, 12), date(2026, 10, 15)
|
||||
await build_feed_day(monday, FeedCRUD(), SeasonCRUD())
|
||||
await build_feed_day(thursday, FeedCRUD(), SeasonCRUD())
|
||||
await build_feed_day(thursday, FeedCRUD(), SeasonCRUD())
|
||||
assert PostType.WEEK.value not in await _posts(monday)
|
||||
assert (await _posts(monday)).count(PostType.WEEK.value) == 1
|
||||
assert (await _posts(thursday)).count(PostType.WEEK.value) == 1
|
||||
assert (await _posts(thursday))[0] == PostType.WEATHER.value
|
||||
|
||||
|
||||
def test_weekends_groups_this_and_next_weekend():
|
||||
from types import SimpleNamespace
|
||||
from services.feed_service import _weekends
|
||||
days = [SimpleNamespace(day=date(2026, 10, 7) + timedelta(days=i)) for i in range(11)]
|
||||
assert [[d.day.day for d in w] for w in _weekends(days)] == [[10, 11], [17]]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_feed_assembles_hero_stories_posts_and_bands(offline):
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||
@@ -125,3 +132,11 @@ async def test_feed_has_quote_and_no_adjacent_same_type(offline):
|
||||
assert all(a != b for a, b in zip(types, types[1:]))
|
||||
assert PostType.QUOTE.value in types
|
||||
assert articles["articles"] and all(a["category"] != 4 for a in articles["articles"])
|
||||
|
||||
|
||||
def test_gak_key_handles_sunset_window():
|
||||
from types import SimpleNamespace
|
||||
from services.feed_service import _gak_key
|
||||
item = SimpleNamespace(definition=SimpleNamespace(windows=[{"around": "sunset", "hours": 1}]), rank=1)
|
||||
assert _gak_key(item, 9) == (0, 8, 1)
|
||||
assert _gak_key(item, 21) == (1, 0, 1)
|
||||
@@ -25,13 +25,24 @@ def _h(hour, feels=21.0, prob=0, rain=RainType.NONE, wind=1.5, hum=50, sky=Sky.C
|
||||
|
||||
|
||||
def test_perfect_evening_scores_100():
|
||||
r = evaluate(_defn(), [[_h(19), _h(20)]], CTX)
|
||||
r = evaluate(_defn(), [[_h(19, wind=1.0), _h(20, wind=1.0)]], CTX)
|
||||
assert r.score == 100 and r.zero_reason is None
|
||||
assert r.notes["temp"] == "체감 21°, 편한 범위 18~24° 안"
|
||||
|
||||
|
||||
def test_temp_outside_range_loses_8_per_degree():
|
||||
assert temp_score({"type": "range", "lo": 18, "hi": 24}, 15)[0] == 76
|
||||
def test_good_but_not_perfect_stays_below_100():
|
||||
assert evaluate(_defn(), [[_h(19, feels=23, hum=58, wind=1.8)]], CTX).score < 95
|
||||
|
||||
|
||||
def test_one_bad_factor_pulls_total_down():
|
||||
assert evaluate(_defn(), [[_h(19, wind=1.0, prob=60)]], CTX).score < 80
|
||||
|
||||
|
||||
def test_temp_peaks_at_best_and_loses_8_per_degree_outside():
|
||||
assert temp_score({"type": "range", "lo": 18, "hi": 24}, 21)[0] == 100
|
||||
assert temp_score({"type": "range", "lo": 18, "hi": 24}, 24)[0] == 85
|
||||
assert temp_score({"type": "range", "lo": 18, "hi": 24, "best": 22}, 22)[0] == 100
|
||||
assert temp_score({"type": "range", "lo": 18, "hi": 24}, 15)[0] == 61
|
||||
assert temp_score({"type": "lower", "zero": 25, "full": 5}, 15)[0] == 50
|
||||
assert temp_score({"type": "range", "lo": 10, "hi": 20, "offset": -6}, 21)[1].startswith("정상 15°")
|
||||
|
||||
|
||||
@@ -10,10 +10,12 @@ async def _get(path: str, **params):
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_region_list_has_all_256_districts():
|
||||
async def test_region_list_is_seoul_gu_and_city_county_elsewhere():
|
||||
body = await _get("/v1/region/list")
|
||||
assert body["result"]["success"] is True
|
||||
assert len(body["regions"]) == 256
|
||||
assert len(body["regions"]) == 230
|
||||
names = {r["name"] for r in body["regions"]}
|
||||
assert "경기 수원시" in names and "경기 수원시 장안구" not in names
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
||||
@@ -61,8 +61,8 @@ def _vilage(*_):
|
||||
|
||||
|
||||
def _mid(*_):
|
||||
land = {f"wf{n}{p}": "맑음" for n in range(4, 8) for p in ("Am", "Pm")} | {f"rnSt{n}{p}": 10 for n in range(4, 8) for p in ("Am", "Pm")}
|
||||
ta = {f"taMin{n}": 11 for n in range(4, 8)} | {f"taMax{n}": 23 for n in range(4, 8)}
|
||||
land = {f"wf{n}{p}": "맑음" for n in range(4, 11) for p in ("Am", "Pm")} | {f"rnSt{n}{p}": 10 for n in range(4, 11) for p in ("Am", "Pm")}
|
||||
ta = {f"taMin{n}": 11 for n in range(4, 11)} | {f"taMax{n}": 23 for n in range(4, 11)}
|
||||
return land, ta
|
||||
|
||||
|
||||
@@ -85,11 +85,11 @@ def fakes(monkeypatch):
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_week_has_seven_days_with_holiday_and_rain(fakes):
|
||||
async def test_week_reaches_mid_forecast_end_with_holiday_and_rain(fakes):
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||
body = (await client.get("/v1/week", params={"region": REGION})).json()
|
||||
days = body["days"]
|
||||
assert len(days) == 7
|
||||
assert 10 <= len(days) <= 11
|
||||
assert days[1]["holiday"] == "테스트공휴일"
|
||||
assert days[2]["is_rainy"] is True and days[2]["rain_hours"] == [15, 16]
|
||||
assert days[6]["temp_max_c"] == 23
|
||||
|
||||
Reference in new issue
Block a user