feat: 지역 검색 페이지 제목을 '성남시 오늘 날씨'로 시작, 요약 앞에 최저·최고·강수확률·하늘
This commit is contained in:
1 parent
a68268234d
commit
882932a51b
3 files changed
+60
-24
No files matched your search
@@ -4,14 +4,15 @@ import pytest
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
||||
from common.utils.kma_time import KST
|
||||
from common.database.model.models import WeatherHourly
|
||||
from router.router import app
|
||||
from router.v1.feed.protocol import Bands, Hero, HeroStat, Res_Feed, TopIndex
|
||||
from services.seo_service import SeoService, fill, today_line
|
||||
from services.seo_service import SeoService, day_summary, fill, today_line
|
||||
|
||||
REGION = "1114000000"
|
||||
TEMPLATE = (
|
||||
'<html><head><meta name="description" content="소개" /><meta property="og:description" content="소개" />'
|
||||
f'<meta name="region-code" content="{REGION}" />\n </head><body><main><h1>오늘 서울 중구 날씨, 뭐 할까?</h1><p>소개 글</p></main></body></html>'
|
||||
f'<meta name="region-code" content="{REGION}" />\n </head><body><main><h1>서울 중구 오늘 날씨, 뭐 할까?</h1><p>소개 글</p></main></body></html>'
|
||||
)
|
||||
|
||||
|
||||
@@ -26,20 +27,30 @@ def _feed() -> Res_Feed:
|
||||
return Res_Feed(hero=hero, stories=stories, bands=Bands(top5=stories[:2]))
|
||||
|
||||
|
||||
def test_today_line_has_temp_status_slot_firsts_and_sunset():
|
||||
line = today_line(_feed(), datetime(2026, 10, 14, 17, 52, tzinfo=KST))
|
||||
assert line == "지금 13°, 습도 보통·미세먼지 좋음. 아침은 러닝각, 낮은 빨래각, 밤은 별보기각. 해 지는 시각 오후 5시 52분."
|
||||
def _hour(h: int, temp: float, sky: int = 1, rain: int = 1, prob: int = 0) -> WeatherHourly:
|
||||
return WeatherHourly(forecast_at=datetime(2026, 10, 14, h, tzinfo=KST), temp_c=temp, sky=sky, rain_type=rain, rain_prob=prob)
|
||||
|
||||
|
||||
def test_day_summary_min_max_prob_and_daytime_sky():
|
||||
rows = [_hour(3, 8.6, sky=4), _hour(9, 12, sky=3), _hour(12, 19.5, sky=1, prob=10), _hour(15, 20.2, sky=1), _hour(21, 14)]
|
||||
assert day_summary(rows) == "최저 9°·최고 20°, 강수확률 10%, 맑음."
|
||||
assert day_summary([_hour(12, 15, rain=2, prob=70)]) == "최저 15°·최고 15°, 강수확률 70%, 비."
|
||||
|
||||
|
||||
def test_today_line_has_day_now_slot_firsts_and_sunset():
|
||||
line = today_line(_feed(), [_hour(12, 19.5, prob=10)], datetime(2026, 10, 14, 17, 52, tzinfo=KST))
|
||||
assert line == "최저 20°·최고 20°, 강수확률 10%, 맑음. 지금 13°, 습도 보통·미세먼지 좋음. 아침은 러닝각, 낮은 빨래각, 밤은 별보기각. 해 지는 시각 오후 5시 52분."
|
||||
|
||||
|
||||
def test_fill_puts_today_into_description_and_body():
|
||||
html = fill(TEMPLATE, _feed(), "서울 중구", None)
|
||||
html = fill(TEMPLATE, _feed(), [], "서울 중구", None)
|
||||
assert html.count('content="지금 13°, 습도 보통·미세먼지 좋음.') == 2
|
||||
assert "<h1>오늘 서울 중구 날씨, 뭐 할까?</h1><p>지금 13°" in html
|
||||
assert "<h1>서울 중구 오늘 날씨, 뭐 할까?</h1><p>지금 13°" in html
|
||||
assert "<li>러닝각 80점</li><li>빨래각 77점</li>" in html
|
||||
|
||||
|
||||
def test_fill_keeps_template_when_no_weather():
|
||||
assert fill(TEMPLATE, Res_Feed(), "서울 중구", None) == TEMPLATE
|
||||
assert fill(TEMPLATE, Res_Feed(), [], "서울 중구", None) == TEMPLATE
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -51,6 +62,6 @@ async def test_today_page_fills_real_feed(offline, monkeypatch):
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||
page = await client.get("/v1/seo/today/seoul/jung")
|
||||
missing = await client.get("/v1/seo/today/seoul/nowhere")
|
||||
assert page.status_code == 200 and "<h1>오늘 서울 중구 날씨, 뭐 할까?</h1><p>지금 20°" in page.text
|
||||
assert page.status_code == 200 and "<h1>서울 중구 오늘 날씨, 뭐 할까?</h1><p>최저 " in page.text and "지금 20°" in page.text
|
||||
assert "해 지는 시각 오후" in page.text and "<ol><li>" in page.text
|
||||
assert missing.status_code == 404
|
||||
Reference in new issue
Block a user