[feat] solution: 템플릿 정의를 templates.json 한 파일로 — 업종 없는 id · 레이아웃 basic/paper 정리

템플릿 정보가 빌더·렌더러·백엔드에 따로 적혀 어긋나 있었다 — 백엔드 기본값이 없는 id 를
가리켰고, 음식점 강조색 오타, 섹션 간격이 빌더와 서버에서 달랐다.

- shared/src/data/templates.json: 템플릿 4개(simple·magazine·retro·paper)와 업종별 허용·기본
- shared/lib/catalog.ts · backend/common/template_catalog.py: 같은 JSON 을 읽는다, 모르는 id 는 에러
- 저장·미리보기·발행에서 모르는 id 를 거절한다(site_service · site.py 422 · build_service 실패)
- site: 레이아웃 등록표(basic·paper) + LayoutProvider, Shell→Frame, HomePage→SectionList
- 연결 안 된 레이아웃 5개, 배치 고르기(variant), 서체 선택, 빌더 canvas/DevShowcase 삭제
- 빌더: 템플릿을 바꾸면 이전 템플릿이 켠 섹션을 끄고 안내 문구를 띄운다
- postgres-init/migrations/0023: stay-retro → retro, 병원 허용 밖은 NULL(운영 미적용)
- Dockerfile·worker: 백엔드 이미지에 shared/src/data 복사
- docs: TEMPLATES.md 신설(세 폴더 역할·템플릿 추가·렌더링 순서), DATA_MODEL·ARCHITECTURE 등 갱신

shared·site·frontend tsc 통과, site vitest 통과, 백엔드 DB 없는 테스트 41 passed(DB 테스트 미실행)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 5.5 committed 2026-09-28 15:57:35 +09:00
1 parent 46b74b310b
commit c6908629f3
183 files changed
+1824 -15243

No files matched your search

+3 -3
View File
@@ -43,12 +43,12 @@ async def test_site_row_is_joined_into_the_line(auth_headers, client):
기대결과: 템플릿·주소가 목록에 그대로 보인다."""
h = await auth_headers("my2")
pid = await _place(client, h, "합쳐진펜션")
await client.post(f"/v1/place/{pid}/site/template", headers=h, json={"template_id": "stay-quiet-margin"})
await client.post(f"/v1/place/{pid}/site/template", headers=h, json={"template_id": "paper"})
await client.post(f"/v1/place/{pid}/site/slug", headers=h, json={"slug": "joined-stay"})
row = (await _list(client, h))["sites"][0]
assert row["site_id"]
assert row["template_id"] == "stay-quiet-margin"
assert row["template_id"] == "paper"
assert row["domain"] == "joined-stay"
assert row["status"] == SiteStatus.DRAFT.value
@@ -107,7 +107,7 @@ async def test_needs_rebuild_matches_the_single_site_answer(auth_headers, client
h = await auth_headers("my4")
pid = await _place(client, h, "고친펜션")
# 템플릿 저장이 사이트 행을 만든다. 그 뒤 노출값이 바뀐 것으로 표시한다.
await client.post(f"/v1/place/{pid}/site/template", headers=h, json={"template_id": "t"})
await client.post(f"/v1/place/{pid}/site/template", headers=h, json={"template_id": "paper"})
async with db_engine.begin() as conn:
await conn.execute(
text("UPDATE places SET content_updated_at = now() WHERE place_id = :pid"),
+37 -53
View File
@@ -1,22 +1,21 @@
"""템플릿(디자인) 선택 저장.
"""템플릿 선택 저장.
이 경로가 절대 하면 안 되는 것:
- 고른 템플릿을 브라우저에만 두는 것 — 발행 잡이 읽을 곳이 없어 업종 기본으로 굽는다.
사장님이 고른 디자인과 실제 발행본이 갈리는 것이 이 API 가 생긴 이유다.
- ★ 발행됐다고 템플릿을 잠그는 것 — 주소(slug)와 달리 디자인은 바뀌어도 URL 이 그대로다.
잠글 이유가 없는 것을 잠그면 사장님이 발행 후에 디자인을 못 바꾼다.
- 바꿔놓고 재빌드 표시를 안 하는 것 — 관리 화면은 새 디자인, 나가 있는 페이지는 옛 디자인이 된다.
- 업종 허용 목록(templates.json)에 없는 템플릿을 저장하는 것.
- 발행됐다고 템플릿을 잠그는 것 — 디자인은 바뀌어도 URL이 그대로다.
- 바꿔 놓고 재빌드 표시를 안 하는 것.
"""
import uuid
from sqlalchemy import text
from common.enums import ErrorType, PlaceCategory, SiteStatus
from services.site_payload import _DEFAULT_THEME, to_site_payload
from common.template_catalog import INDUSTRIES
from services.site_payload import to_site_payload
async def _place(client, headers, name="템플릿펜션"):
r = await client.post("/v1/place", headers=headers, json={"name": name, "category": 1})
async def _place(client, headers, name="템플릿펜션", category=1):
r = await client.post("/v1/place", headers=headers, json={"name": name, "category": category})
return r.json()["place"]["place_id"]
@@ -30,97 +29,82 @@ async def _get_site(client, headers, pid):
async def test_set_template_creates_site_row(auth_headers, client):
"""검증: 사이트 행이 없어도 템플릿을 먼저 고를 수 있다(고르는 건 발행보다 앞선 결정이다).
기대결과: SUCCESS + 저장된 값이 조회에도 그대로 나온다."""
"""검증: 사이트 행이 없어도 템플릿을 먼저 고를 수 있고, 조회에도 그대로 나온다."""
h = await auth_headers("tpl1")
pid = await _place(client, h)
saved = await _set_template(client, h, pid, "stay-quiet-margin")
saved = await _set_template(client, h, pid, "paper")
assert saved["result"]["code"] == ErrorType.SUCCESS.value
assert saved["site"]["template_id"] == "stay-quiet-margin"
# 화면이 "지금 어느 템플릿으로 나가는지"를 조회로 다시 읽을 수 있어야 한다.
assert (await _get_site(client, h, pid))["site"]["template_id"] == "stay-quiet-margin"
assert saved["site"]["template_id"] == "paper"
assert (await _get_site(client, h, pid))["site"]["template_id"] == "paper"
async def test_unknown_template_key_is_accepted(auth_headers, client):
"""검증: ★ 서버는 값을 검증하지 않는다 — 템플릿 목록은 프론트가 소유한다.
기대결과: 모르는 키도 저장된다(화이트리스트를 두면 템플릿 하나 늘릴 때마다 백엔드를 고쳐야 한다)."""
async def test_unknown_template_is_refused(auth_headers, client):
"""검증: 등록되지 않은 id는 거절한다."""
h = await auth_headers("tpl2")
pid = await _place(client, h)
saved = await _set_template(client, h, pid, "brand-new-template-nobody-knows")
assert saved["result"]["code"] == ErrorType.SUCCESS.value
assert saved["site"]["template_id"] == "brand-new-template-nobody-knows"
async def test_too_long_template_is_refused(auth_headers, client):
"""검증: 길이(varchar(100))만은 막는다 — 안 막으면 DB 가 트랜잭션째로 튕긴다.
기대결과: INVALID_REQUEST_DATA."""
h = await auth_headers("tpl3")
pid = await _place(client, h)
refused = await _set_template(client, h, pid, "t" * 101)
refused = await _set_template(client, h, pid, "stay-retro")
assert refused["result"]["code"] == ErrorType.INVALID_REQUEST_DATA.value
assert "site" not in refused
async def test_template_outside_industry_list_is_refused(auth_headers, client):
"""검증: 등록된 템플릿이라도 그 업종 허용 목록에 없으면 거절한다(병원은 레트로를 못 쓴다)."""
h = await auth_headers("tpl3")
pid = await _place(client, h, name="템플릿의원", category=PlaceCategory.CLINIC.value)
refused = await _set_template(client, h, pid, "retro")
assert refused["result"]["code"] == ErrorType.INVALID_REQUEST_DATA.value
async def test_empty_value_clears_to_default(auth_headers, client):
"""검증: 빈 값은 '고르지 않음'이다 — NULL 로 되돌아가 업종 기본으로 떨어진다.
기대결과: 저장 후 빈 문자열을 보내면 template_id 가 응답에서 사라진다(None)."""
"""검증: 빈 값은 '고르지 않음'이다 — NULL로 돌아가 업종 기본 템플릿으로 나간다."""
h = await auth_headers("tpl4")
pid = await _place(client, h)
await _set_template(client, h, pid, "stay-quiet-margin")
await _set_template(client, h, pid, "paper")
cleared = await _set_template(client, h, pid, "")
assert cleared["result"]["code"] == ErrorType.SUCCESS.value
# RemoveNoneResponse 가 None 필드를 지운다 — 키가 없으면 NULL 이다.
assert "template_id" not in cleared["site"]
async def test_published_site_template_is_not_locked(auth_headers, client, db_engine):
"""검증: ★ 발행된 사이트도 템플릿은 바꿀 수 있다(주소와 다르다 — URL 이 그대로라 색인이 안 깨진다).
기대결과: SUCCESS + 재빌드 필요 표시(needs_rebuild)."""
"""검증: 발행된 사이트도 템플릿을 바꿀 수 있고, 재빌드 표시가 선다."""
h = await auth_headers("tpl5")
pid = await _place(client, h)
await _set_template(client, h, pid, "stay-o2o-editorial")
await _set_template(client, h, pid, "simple")
# 발행 상태를 만든다(빌드 잡을 돌리는 대신 상태만).
async with db_engine.begin() as conn:
await conn.execute(
text("UPDATE sites SET status = :st, published_at = now() WHERE place_id = :p"),
{"st": SiteStatus.PUBLISHED.value, "p": uuid.UUID(pid)},
)
changed = await _set_template(client, h, pid, "stay-quiet-margin")
changed = await _set_template(client, h, pid, "paper")
assert changed["result"]["code"] == ErrorType.SUCCESS.value
assert changed["site"]["template_id"] == "stay-quiet-margin"
# 나가 있는 페이지와 달라졌으므로 이 사업장만 다시 빌드하면 된다는 표시가 서야 한다.
assert changed["site"]["template_id"] == "paper"
assert changed["needs_rebuild"] is True
async def test_other_owners_place_is_blocked(auth_headers, client):
"""검증: 남의 사업장의 템플릿은 바꿀 수 없다.
기대결과: PLACE_NOT_FOUND(존재 여부조차 알려주지 않는다)."""
"""검증: 남의 사업장의 템플릿은 바꿀 수 없다(PLACE_NOT_FOUND)."""
h = await auth_headers("tpl6")
intruder = await auth_headers("tpl7")
pid = await _place(client, h)
blocked = await _set_template(client, intruder, pid, "stay-quiet-margin")
blocked = await _set_template(client, intruder, pid, "paper")
assert blocked["result"]["code"] == ErrorType.PLACE_NOT_FOUND.value
def test_payload_uses_saved_template_and_falls_back():
"""검증: 발행 payload 의 theme.templateId 는 저장된 값을 쓰고, 없으면 업종 기본으로 떨어진다.
기대결과: 저장값 → 그대로 / NULL → 업종 기본. ★ 고르지 않은 값을 고른 것처럼 굽지 않는다."""
"""검증: payload의 templateId는 저장값, 없으면 업종 기본 템플릿이다."""
place = {"place_id": uuid.uuid4(), "category": PlaceCategory.LODGING.value, "name": "스테이,머뭄"}
snapshot = {"place": {"name": "스테이,머뭄", "category": PlaceCategory.LODGING.value}}
version = {"version": 1}
chosen = to_site_payload(place, snapshot, {"template_id": "stay-quiet-margin"}, version, [])
assert chosen["theme"]["templateId"] == "stay-quiet-margin"
chosen = to_site_payload(place, snapshot, {"template_id": "paper"}, version, [])
assert chosen["theme"]["templateId"] == "paper"
default_id = _DEFAULT_THEME[PlaceCategory.LODGING.value]["templateId"]
assert to_site_payload(place, snapshot, {"template_id": None}, version, [])["theme"]["templateId"] == default_id
# 색·서체는 여전히 업종 기본이다(그 값들은 아직 저장되는 자리가 없다).
assert chosen["theme"]["fontStyle"] == _DEFAULT_THEME[PlaceCategory.LODGING.value]["fontStyle"]
fallback = to_site_payload(place, snapshot, {"template_id": None}, version, [])
assert fallback["theme"]["templateId"] == INDUSTRIES["stay"]["defaultTemplate"]
+46 -91
View File
@@ -5,29 +5,25 @@
사장님이 섹션을 끄고 순서를 바꿔도 발행본이 안 바뀌던 것이 이 API 가 생긴 이유다.
- ★ 잠긴 섹션(SEO·필수 마크업)을 끈 채로 내보내는 것 — 끄기로도, 목록에서 빼기로도 막아야 한다.
한쪽만 막으면 "끄는 대신 빼면 그만"이라 잠금이 무의미해진다.
- 저장값을 서버가 해석하는 것 — 섹션 목록·배리에이션 키는 프론트가 소유한다.
화이트리스트를 두면 프론트에 항목 하나 늘 때마다 백엔드를 같이 고쳐야 한다.
- 템플릿 정의(templates.json)에 없는 모양·템플릿으로 굽는 것.
- templateId 를 theme 안에 같이 보관하는 것 — sites.template_id 와 갈린다.
"""
import uuid
import pytest
import pathlib
import re
from sqlalchemy import text
from common.enums import ErrorType, PlaceCategory, SiteStatus
from services.site_payload import _DEFAULT_THEME, to_site_payload
from common.template_catalog import INDUSTRIES, TEMPLATES, UnknownTemplate
from services.site_payload import to_site_payload
# 계약 그대로의 최소 테마. 배열 순서가 곧 섹션 순서다(별도 order 필드가 없다).
_THEME = {
"colors": {"accent": "#c2410c"},
"fontStyle": "Warm Serif",
"colorPaletteId": "warm-sand",
"sections": [
{"id": "faq", "name": "자주 묻는 질문", "enabled": True, "locked": False, "variantId": "faq.two-column"},
{"id": "faq", "name": "자주 묻는 질문", "enabled": True, "locked": False},
{"id": "hero", "name": "우리 히어로", "enabled": True, "locked": True},
{"id": "rooms", "name": "객실 안내", "enabled": False, "locked": False},
],
@@ -61,17 +57,15 @@ async def test_set_theme_creates_site_row_and_round_trips(auth_headers, client):
assert (await _get_site(client, h, pid))["site"]["theme"] == _THEME
async def test_unknown_sections_and_variants_are_accepted(auth_headers, client):
"""검증: ★ 서버는 값을 해석하지 않는다 — 섹션 목록·배리에이션 키는 프론트가 소유한다.
기대결과: 백엔드가 처음 보는 섹션 id 와 배리에이션 키도 그대로 저장된다."""
async def test_unknown_sections_are_accepted(auth_headers, client):
"""검증: 빌더가 새로 추가한 섹션 id도 그대로 저장된다."""
h = await auth_headers("thm2")
pid = await _place(client, h)
theme = {"sections": [{"id": "brand-new-section", "name": "신규", "enabled": True,
"locked": False, "variantId": "nobody.knows"}]}
theme = {"sections": [{"id": "brand-new-section", "name": "신규", "enabled": True, "locked": False}]}
saved = await _set_theme(client, h, pid, theme)
assert saved["result"]["code"] == ErrorType.SUCCESS.value
assert saved["site"]["theme"]["sections"][0]["variantId"] == "nobody.knows"
assert saved["site"]["theme"]["sections"][0]["id"] == "brand-new-section"
async def test_oversized_theme_is_refused(auth_headers, client):
@@ -80,7 +74,7 @@ async def test_oversized_theme_is_refused(auth_headers, client):
h = await auth_headers("thm3")
pid = await _place(client, h)
refused = await _set_theme(client, h, pid, {"fontStyle": "x" * 70_000})
refused = await _set_theme(client, h, pid, {"colors": {"accent": "x" * 70_000}})
assert refused["result"]["code"] == ErrorType.INVALID_REQUEST_DATA.value
assert "site" not in refused
@@ -91,10 +85,10 @@ async def test_template_id_is_not_stored_inside_theme(auth_headers, client):
h = await auth_headers("thm4")
pid = await _place(client, h)
saved = await _set_theme(client, h, pid, {"templateId": "sneaky", "fontStyle": "폰트"})
saved = await _set_theme(client, h, pid, {"templateId": "sneaky", "colors": {"accent": "#000000"}})
assert saved["result"]["code"] == ErrorType.SUCCESS.value
assert "templateId" not in saved["site"]["theme"]
assert saved["site"]["theme"]["fontStyle"] == "폰트"
assert saved["site"]["theme"]["colors"] == {"accent": "#000000"}
async def test_empty_theme_clears_to_default(auth_headers, client):
@@ -123,7 +117,7 @@ async def test_published_site_theme_is_not_locked(auth_headers, client, db_engin
{"st": SiteStatus.PUBLISHED.value, "p": uuid.UUID(pid)},
)
changed = await _set_theme(client, h, pid, {**_THEME, "fontStyle": "다른서체"})
changed = await _set_theme(client, h, pid, {**_THEME, "colors": {"accent": "#111111"}})
assert changed["result"]["code"] == ErrorType.SUCCESS.value
# 나가 있는 페이지와 달라졌으므로 이 사업장만 다시 빌드하면 된다는 표시가 서야 한다.
assert changed["needs_rebuild"] is True
@@ -149,17 +143,16 @@ def _payload_theme(theme):
return to_site_payload(_PLACE, _SNAPSHOT, {"template_id": None, "theme": theme}, _VERSION, [])["theme"]
def test_payload_without_saved_theme_falls_back_to_category_default():
"""검증: 저장된 디자인이 없을 때.
기대결과: 업종 기본 색·서체·섹션 그대로 — 고르지 않은 값을 고른 것처럼 굽지 않는다."""
spec = _DEFAULT_THEME[PlaceCategory.LODGING.value]
def test_payload_without_saved_theme_uses_industry_default():
"""검증: 저장된 디자인이 없으면 업종 기본 템플릿(숙박=retro)과 업종 섹션 목록 그대로 나간다."""
theme = _payload_theme(None)
stay = INDUSTRIES["stay"]
assert theme["fontStyle"] == spec["fontStyle"]
assert theme["colors"] == spec["colors"]
assert [s["id"] for s in theme["sections"]] == [sid for sid, _, _ in spec["sections"]]
assert all(s["enabled"] for s in theme["sections"] if s["id"] != "social")
assert next(s for s in theme["sections"] if s["id"] == "social")["enabled"] is False
assert theme["templateId"] == "retro"
assert theme["colors"] == TEMPLATES["retro"]["colors"]
assert theme["look"] == TEMPLATES["retro"]["look"]
assert [s["id"] for s in theme["sections"]] == [s["id"] for s in stay["sections"]]
assert [s["enabled"] for s in theme["sections"]] == [s["enabled"] for s in stay["sections"]]
def test_payload_follows_saved_order_and_toggles():
@@ -171,13 +164,17 @@ def test_payload_follows_saved_order_and_toggles():
assert next(s for s in theme["sections"] if s["id"] == "rooms")["enabled"] is False
def test_payload_carries_variant_id_only_when_chosen():
"""검증: 배리에이션은 그대로 싣되, 고르지 않았으면 키 자체를 붙이지 않는다.
기대결과: 고른 섹션엔 variantId, 안 고른 섹션엔 키 없음
(null 을 실으면 렌더러 타입과 안 맞고, 비면 렌더러가 기본 레이아웃으로 떨어진다)."""
theme = _payload_theme(_THEME)
assert next(s for s in theme["sections"] if s["id"] == "faq")["variantId"] == "faq.two-column"
assert "variantId" not in next(s for s in theme["sections"] if s["id"] == "hero")
def test_payload_drops_variant_id():
"""검증: 배치 고르기를 뺐으므로 저장값에 variantId가 남아 있어도 payload에 싣지 않는다."""
theme = _payload_theme({"sections": [{"id": "faq", "name": "FAQ", "enabled": True, "locked": False,
"variantId": "faq.two-column"}]})
assert "variantId" not in next(s for s in theme["sections"] if s["id"] == "faq")
def test_payload_ignores_saved_look():
"""검증: 모양(look)은 템플릿 정의가 정한다. 저장값의 look은 무시한다."""
theme = _payload_theme({"look": {"fontHeading": "Comic Sans"}})
assert theme["look"] == TEMPLATES["retro"]["look"]
def test_locked_section_cannot_be_published_disabled():
@@ -237,13 +234,11 @@ def test_owner_written_section_body_reaches_publish_payload():
def test_partial_colors_are_filled_from_category_default():
"""검증: 저장된 색이 일부 키만 담고 있을 때.
기대결과: 빠진 자리는 업종 기본이 메운다 — 렌더러 타입이 6개를 모두 요구하므로
일부만 실으면 나머지 색이 undefined 로 나가 화면이 깨진다."""
spec = _DEFAULT_THEME[PlaceCategory.LODGING.value]
기대결과: 빠진 자리는 템플릿 색이 메운다(렌더러는 6개를 모두 요구한다)."""
colors = _payload_theme({"colors": {"accent": "#c2410c"}})["colors"]
assert colors["accent"] == "#c2410c"
assert colors["bg"] == spec["colors"]["bg"]
assert set(colors) == set(spec["colors"])
assert colors["bg"] == TEMPLATES["retro"]["colors"]["bg"]
assert set(colors) == set(TEMPLATES["retro"]["colors"])
def test_color_palette_id_never_reaches_the_payload():
@@ -254,57 +249,17 @@ def test_color_palette_id_never_reaches_the_payload():
def test_saved_theme_does_not_override_chosen_template():
"""검증: templateId 의 출처.
기대결과: 언제나 sites.template_id 다 — theme 는 색·서체·섹션만 담당한다."""
payload = to_site_payload(
_PLACE, _SNAPSHOT, {"template_id": "stay-quiet-margin", "theme": _THEME}, _VERSION, []
)
assert payload["theme"]["templateId"] == "stay-quiet-margin"
"""검증: templateId와 모양은 언제나 sites.template_id가 가리키는 템플릿에서 온다."""
payload = to_site_payload(_PLACE, _SNAPSHOT, {"template_id": "paper", "theme": _THEME}, _VERSION, [])
assert payload["theme"]["templateId"] == "paper"
assert payload["theme"]["look"] == TEMPLATES["paper"]["look"]
# ── 에디터 기본 섹션표와의 1:1 대조 ────────────────────────────────────────
# ★ 이 두 표가 어긋나면 발행본에서 섹션이 통째로 사라진다. 저장된 테마가 없는 사업장
# (위저드만 돌고 [디자인] 탭을 건드리지 않은 대부분)은 _DEFAULT_THEME 이 곧 발행본이라,
# 여기에 없는 섹션은 사장님이 에디터에서 아무리 봐도 사이트에 나오지 않는다.
# 실측으로 날씨·실시간 예약·대관 문의·관람 안내가 그렇게 빠져 있었다.
_ADMIN_SECTIONS_TS = (
pathlib.Path(__file__).resolve().parents[2] / "frontend/src/data/industryData.ts" # parents[2] = solution/
)
# 에디터 업종 키 → PlaceCategory. 이름이 다른 건 두 층의 어휘가 달라서다(clinic vs CLINIC).
_INDUSTRY_TO_CATEGORY = {
"stay": PlaceCategory.LODGING.value,
"cafe": PlaceCategory.CAFE.value,
"restaurant": PlaceCategory.RESTAURANT.value,
"clinic": PlaceCategory.CLINIC.value,
}
def _editor_sections() -> dict[str, list[tuple[str, str, bool]]]:
"""industryData.ts 의 업종별 sections 를 (id, name, locked) 목록으로 읽는다.
★ TS 를 정규식으로 읽는 건 곱지 않지만, 이 표를 백엔드로 복사해 오면 복사본이 또 어긋난다.
원본을 그대로 읽어 비교하는 것이 이 테스트의 요점이다."""
src = _ADMIN_SECTIONS_TS.read_text(encoding="utf-8")
out: dict[str, list[tuple[str, str, bool]]] = {}
for block in re.finditer(r"^ (\w+): \{$(.*?)^ \},$", src, re.S | re.M):
industry = block.group(1)
body = block.group(2)
arr = re.search(r"^ sections: \[$(.*?)^ \],$", body, re.S | re.M)
if not arr:
continue
items = re.findall(
r"id: '([\w]+)', type: '[\w]+', name: '([^']*)', isLocked: (true|false)", arr.group(1)
)
out[industry] = [(sid, name, locked == "true") for sid, name, locked in items]
return out
@pytest.mark.parametrize("industry", sorted(_INDUSTRY_TO_CATEGORY))
def test_default_sections_match_the_editor(industry):
"""검증: 업종 기본 섹션표가 에디터(industryData.ts)와 id·순서·이름·잠금까지 같은가.
기대결과: 완전히 같다 — 여기가 어긋나면 에디터에는 보이는 섹션이 발행본에 없다."""
editor = _editor_sections()
assert industry in editor, f"industryData.ts 에서 {industry} 의 sections 를 읽지 못했다"
server = _DEFAULT_THEME[_INDUSTRY_TO_CATEGORY[industry]]["sections"]
assert [tuple(s) for s in server] == editor[industry]
def test_unknown_template_stops_the_payload():
"""검증: 등록되지 않은 id, 업종 허용 목록에 없는 id는 payload를 만들지 않는다."""
with pytest.raises(UnknownTemplate):
to_site_payload(_PLACE, _SNAPSHOT, {"template_id": "stay-retro"}, _VERSION, [])
clinic = {**_PLACE, "category": PlaceCategory.CLINIC.value}
clinic_snapshot = {"place": {"name": "테마의원", "category": PlaceCategory.CLINIC.value}}
with pytest.raises(UnknownTemplate):
to_site_payload(clinic, clinic_snapshot, {"template_id": "retro"}, _VERSION, [])