merge: origin/main 을 main 에 병합 — 온톨로지 배포 전 동기화

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
HyeongBaeYangandClaude Opus 5.5 committed 2026-10-01 15:05:25 +09:00
commit c7749662fd
63 files changed
+948 -407

No files matched your search

@@ -0,0 +1,26 @@
"""순환 문구 글 형식 — 사장님이 줄 단위로 고친 글이 그대로 계절·월·날씨 문구로 읽혀야 한다."""
from services import catchphrase_text
def test_round_trips_every_kind():
items = [
{"text": "백 년 된 집에서 하룻밤", "kind": "general"},
{"text": "봄에는 대문을 열어 둡니다", "kind": "season", "season": "봄"},
{"text": "새해 첫 아침을 이 집에서", "kind": "month", "month": 1},
{"text": "기와에 빗소리가 납니다", "kind": "weather", "weather": "비"},
]
text = catchphrase_text.encode(items)
assert text.splitlines() == [
"백 년 된 집에서 하룻밤",
"봄 | 봄에는 대문을 열어 둡니다",
"1월 | 새해 첫 아침을 이 집에서",
"비 | 기와에 빗소리가 납니다",
]
assert catchphrase_text.decode(text) == items
def test_unknown_tag_stays_a_general_line():
assert catchphrase_text.decode("장마 | 비가 옵니다\n\n 13월 | 없는 달 ") == [
{"text": "장마 | 비가 옵니다", "kind": "general"},
{"text": "13월 | 없는 달", "kind": "general"},
]
+29 -2
View File
@@ -30,6 +30,15 @@ def _patch(monkeypatch, copy):
monkeypatch.setattr(gemini_text, "generate_copy", _gen)
async def _phrases(place_name, facts, **kw):
return gemini_text.GeneratedCatchphrases(
tagline="체크인 오후 세 시, 조용한 집",
items=[{"text": "짐을 풀면 골목부터 걸어 보세요", "kind": "general"},
{"text": "봄에는 창을 열어 둡니다", "kind": "season", "season": "봄"}],
)
monkeypatch.setattr(gemini_text, "generate_catchphrases", _phrases)
async def _place_with_facts(client, h, n_verified=5):
pid = (await client.post("/v1/place", headers=h, json={"name": "카피펜션", "category": 1})).json()["place"]["place_id"]
@@ -96,7 +105,7 @@ async def test_resume_reuses_completed_job(auth_headers, client, db_engine, monk
job = (await client.get(f"/v1/job/{first['job_id']}", headers=h)).json()["job"]
assert job["place_id"] == pid
assert [(s["id"], s["status"]) for s in job["progress"]["steps"]] == [
("prepare", "done"), ("generate", "done"), ("save", "done"), ("faq_fill", "done"),
("prepare", "done"), ("generate", "done"), ("save", "done"), ("catchphrase", "done"), ("faq_fill", "done"),
]
fresh = (await client.post(path, headers=h, json={})).json()
assert fresh["job_id"] != first["job_id"]
@@ -111,7 +120,7 @@ async def test_copy_progress_is_visible_during_generation(auth_headers, client,
async def generate(*args, **kwargs):
row = await JobQueue().get(started["job_id"])
assert row["status"] == JobStatus.RUNNING.value
assert [step["status"] for step in row["progress"]["steps"]] == ["done", "running", "pending", "pending"]
assert [step["status"] for step in row["progress"]["steps"]] == ["done", "running", "pending", "pending", "pending"]
return _copy()
monkeypatch.setattr(gemini_text, "generate_copy", generate)
@@ -303,3 +312,21 @@ async def test_copy_requires_api_key(auth_headers, client, monkeypatch):
pid = await _place_with_facts(client, h)
r = await client.post(f"/v1/place/{pid}/copy", headers=h, json={})
assert r.json()["result"]["code"] == ErrorType.GENERATOR_NOT_CONFIGURED.value
async def test_copy_writes_one_catchphrase_and_the_rotating_lines(auth_headers, client, db_engine, monkeypatch):
_patch(monkeypatch, _copy())
h = await auth_headers("catchphrase-owner")
pid = await _place_with_facts(client, h)
job_id = (await client.post(f"/v1/place/{pid}/copy", headers=h, json={})).json()["job_id"]
await Worker("w", JobQueue(), build_handler(), job_deadline_sec=30).drain()
job = (await client.get(f"/v1/job/{job_id}", headers=h)).json()["job"]
assert job["result"]["catchphrase"]["tagline"] is True
assert job["result"]["catchphrase"]["catchphrases"] == 2
async with db_engine.begin() as c:
rows = dict((await c.execute(
text("SELECT key, value FROM place_facts WHERE place_id = :p AND key IN ('tagline', 'catchphrases')"),
{"p": uuid.UUID(pid)},
)).all())
assert rows["tagline"] == "체크인 오후 세 시, 조용한 집"
assert rows["catchphrases"] == "짐을 풀면 골목부터 걸어 보세요\n봄 | 봄에는 창을 열어 둡니다"
@@ -377,3 +377,34 @@ async def test_summarize_empty_text_returns_none():
"""검증: 빈 문자열."""
result = await gt.summarize_text(" ")
assert result is None
# ── 첫 화면 문구 ───────────────────────────────────────────────────────────
def _phrase_payload(body):
return {
"candidates": [{"content": {"parts": [{"text": json.dumps(body, ensure_ascii=False)}]}, "finishReason": "STOP"}],
"usageMetadata": {"promptTokenCount": 800, "candidatesTokenCount": 400},
}
async def test_catchphrases_keep_only_grounded_lines_of_the_right_shape():
body = {
"tagline": "주차하고 바로 쉬는 집",
"general": ["짐을 풀면 골목부터 걸어 보세요", "오션뷰 수영장이 있습니다", "짧다", "하조대펜션에서 쉬세요"],
"season": [{"season": "봄", "text": "봄에는 창을 열어 둡니다"}, {"season": "장마", "text": "비가 오래 오는 계절입니다"}],
"month": [{"month": 1, "text": "새해 첫 아침을 조용히"}, {"month": 13, "text": "없는 달의 문구입니다"}],
"weather": [{"weather": "비", "text": "빗소리를 들으며 쉬세요"}],
}
async with _client(_ok(_phrase_payload(body))) as c:
res = await gt.generate_catchphrases("하조대펜션", FACTS, client=c)
assert res.tagline == "주차하고 바로 쉬는 집"
assert res.items == [
{"text": "짐을 풀면 골목부터 걸어 보세요", "kind": "general"},
{"text": "봄에는 창을 열어 둡니다", "kind": "season", "season": "봄"},
{"text": "새해 첫 아침을 조용히", "kind": "month", "month": 1},
{"text": "빗소리를 들으며 쉬세요", "kind": "weather", "weather": "비"},
]
reasons = dict(res.rejected)
assert "오션뷰 수영장이 있습니다" in reasons
assert reasons["짧다"].startswith("길이")
assert reasons["하조대펜션에서 쉬세요"] == "상호명 포함"