[^<]*
)") +_TITLE = re.compile(r"{escape(line)}
{extra}", html, count=1) +def _ranks(feed: Res_Feed, name: str) -> str: + top = feed.bands.top5 if feed.bands else [] + return f"오늘 {escape(name)} 각 순위
- {''.join(f'
- {escape(t.name)} {t.score}점 ' for t in top)}
오늘 {escape(name)} 각 순위
- {''.join(f'
- {escape(t.name)} {t.score}점 ' for t in top)}
서울 중구 내일 날씨, 뭐 할까?
최저 " in page.text assert "지금 " not in page.text and "
- " not in page.text
assert missing.status_code == 404
+
+
+def test_today_copy_has_date_place_morning_day_firsts_and_status():
+ line = today_copy(date(2026, 10, 14), "중구", _feed(), [_hour(12, 19.5, prob=10)], datetime(2026, 10, 14, 17, 52, tzinfo=KST))
+ assert line == "10월 14일(수) 중구 오늘 날씨: 최저 20°·최고 20°, 비 올 확률 10%. 아침엔 러닝각, 낮엔 빨래각이 1위예요. 미세먼지 좋음, 해 지는 시각 오후 5시 52분."
+ same = _feed()
+ same.stories = [_top("캠핑각", 90, {"morning": 1, "day": 1})]
+ assert "아침·낮엔 캠핑각이 1위예요." in today_copy(date(2026, 10, 14), "중구", same, [], None)
+
+
+def test_today_copy_lists_dust_discomfort_uv_in_order():
+ feed = _feed()
+ feed.hero.status = [HeroStat(icon="m", label=label, value=value, tone="normal") for label, value in (("습도", "보통"), ("불쾌지수", "쾌적"), ("자외선", "보통"), ("미세먼지", "보통"))]
+ line = today_copy(date(2026, 10, 30), "성남시", feed, [_hour(12, 18, rain=2, prob=60)], None)
+ assert line.endswith("미세먼지 보통, 불쾌지수 쾌적, 자외선 보통.")
+ assert "습도" not in line
+
+
+def test_tomorrow_copy_has_date_place_top1_and_sunset():
+ sunset = datetime(2026, 10, 31, 17, 36, tzinfo=KST)
+ line = tomorrow_copy(date(2026, 10, 31), "평택시", [_hour(12, 15, prob=30)], "빨래각", sunset)
+ assert line == "10월 31일(토) 평택시 내일 날씨: 최저 15°·최고 15°, 맑음, 비 올 확률 30%. 내일 하기 좋은 일 1위는 빨래각, 해 지는 시각은 오후 5시 36분이에요."
+ on_hour = tomorrow_copy(date(2026, 10, 31), "평택시", [_hour(12, 15)], None, datetime(2026, 10, 31, 18, 0, tzinfo=KST))
+ assert on_hour.endswith("해 지는 시각은 오후 6시예요.")
+ assert tomorrow_copy(date(2026, 10, 31), "평택시", [], "빨래각", sunset) == ""
+
+
+@pytest.mark.anyio
+async def test_new_copy_pages_get_new_title_and_description(offline, monkeypatch):
+ tomorrow = TEMPLATE.replace("오늘 날씨", "내일 날씨").replace("", "
- " in today.text and '' in today.text
+ assert " 중구 내일 날씨: 최저 " in ahead.text and "해 지는 시각은 오후" in ahead.text
+ assert "
중구 내일 날씨 · 내일 1위는 " in ahead.text and 'property="og:description" content="10월 ' in ahead.text + assert '' in ahead.text + + +@pytest.mark.anyio +async def test_old_copy_pages_keep_old_text_and_are_marked(offline, monkeypatch): + async def template(self, path): + return TEMPLATE if path == "today/seoul/jung" else None + + monkeypatch.setattr(SeoService, "template", template) + monkeypatch.setattr(seo_service, "NEW_COPY", frozenset()) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + page = await client.get("/v1/seo/today/seoul/jung") + assert " 서울 중구 오늘 날씨, 뭐 할까?
최저 " in page.text + assert '' in page.text + + +def test_copy_test_groups_split_region_pages_in_half(): + assert seo_service.NEW_COPY and all(p.startswith(("today/", "tomorrow/")) for p in seo_service.NEW_COPY) + today = sum(p.startswith("today/") for p in seo_service.NEW_COPY) + assert today == len(seo_service.NEW_COPY) - today