fix(cafe24): 앞 커밋에서 누락된 디자인파일 일반화 변경분 포함
config.py(Cafe24FtpConfig 일반화 + DESIGN_FILE_SPECS)·db.py(add/list_design_
revision)·router.py(design_files_router 연결)·_nav.html(탭 3개)·테스트·
.env.example·문서가 앞 커밋(8c2a9c4)에 함께 올라갔어야 하는데 스테이징 누락.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -665,7 +665,7 @@ def test_update_product_sends_flags_and_html():
|
||||
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 모바일 스와이프(product-swiper.js) — 디자인 보관함 FTP
|
||||
# 디자인 보관함 FTP — 모바일 스와이프 / PC·모바일 상품상세 템플릿
|
||||
# ════════════════════════════════════════════════════════════
|
||||
def test_ftp_config_host_falls_back_to_mall_id():
|
||||
"""CAFE24_FTP_HOST 미설정 시 카페24 규칙({mall_id}.ftp.cafe24.com)을 쓴다."""
|
||||
@@ -680,16 +680,37 @@ def test_ftp_config_host_falls_back_to_mall_id():
|
||||
|
||||
|
||||
def test_ftp_config_missing_lists_absent_vars():
|
||||
cfg = cfgmod.Cafe24FtpConfig(host="", port=21, user="", password="", swiper_path="")
|
||||
cfg = cfgmod.Cafe24FtpConfig(host="", port=21, user="", password="")
|
||||
assert cfg.configured is False
|
||||
assert cfg.missing == [
|
||||
"CAFE24_FTP_HOST", "CAFE24_FTP_USER", "CAFE24_FTP_PASSWORD", "CAFE24_SWIPER_FTP_PATH",
|
||||
]
|
||||
full = cfgmod.Cafe24FtpConfig(host="h", port=21, user="u", password="p", swiper_path="/x.js")
|
||||
assert cfg.missing == ["CAFE24_FTP_HOST", "CAFE24_FTP_USER", "CAFE24_FTP_PASSWORD"]
|
||||
full = cfgmod.Cafe24FtpConfig(host="h", port=21, user="u", password="p")
|
||||
assert full.configured is True
|
||||
assert full.missing == []
|
||||
|
||||
|
||||
def test_design_file_specs_cover_all_three_files():
|
||||
"""상단 탭 3개(모바일 스와이프/모바일 상품상세/PC 상품상세)가 모두 등록돼 있는가."""
|
||||
assert set(cfgmod.DESIGN_FILE_SPECS) == {"swiper", "mobile_detail", "pc_detail"}
|
||||
assert cfgmod.design_file_label("swiper") == "모바일 스와이프"
|
||||
assert cfgmod.design_file_label("mobile_detail") == "모바일 상품상세"
|
||||
assert cfgmod.design_file_label("pc_detail") == "PC 상품상세"
|
||||
# 기본 경로(env 미설정 시) — 실물 확인된 값
|
||||
assert cfgmod.design_file_path("mobile_detail") == "/sde_design/mobile11/product/detail.html"
|
||||
assert cfgmod.design_file_path("pc_detail") == "/sde_design/skin11/product/detail.html"
|
||||
|
||||
|
||||
def test_design_file_path_env_override():
|
||||
saved = os.environ.get("CAFE24_PC_DETAIL_FTP_PATH")
|
||||
os.environ["CAFE24_PC_DETAIL_FTP_PATH"] = "/sde_design/skin99/product/detail.html"
|
||||
try:
|
||||
assert cfgmod.design_file_path("pc_detail") == "/sde_design/skin99/product/detail.html"
|
||||
finally:
|
||||
if saved is None:
|
||||
os.environ.pop("CAFE24_PC_DETAIL_FTP_PATH", None)
|
||||
else:
|
||||
os.environ["CAFE24_PC_DETAIL_FTP_PATH"] = saved
|
||||
|
||||
|
||||
class _FakeFTP:
|
||||
"""ftplib.FTP 대역 — 실제 소켓 없이 RETR/STOR 명령만 흉내낸다."""
|
||||
|
||||
@@ -724,19 +745,17 @@ class _FakeFTP:
|
||||
def test_design_ftp_read_and_write_roundtrip():
|
||||
from app.integrations.cafe24 import design_ftp
|
||||
|
||||
_FakeFTP.files = {"/sde_design/mobile11/product-swiper/product-swiper.js": "old".encode("utf-8")}
|
||||
path = "/sde_design/mobile11/product-swiper/product-swiper.js"
|
||||
_FakeFTP.files = {path: "old".encode("utf-8")}
|
||||
saved = ftplib.FTP
|
||||
ftplib.FTP = _FakeFTP
|
||||
try:
|
||||
cfg = cfgmod.Cafe24FtpConfig(
|
||||
host="h", port=21, user="u", password="p",
|
||||
swiper_path="/sde_design/mobile11/product-swiper/product-swiper.js",
|
||||
)
|
||||
content = design_ftp.read_text_file(cfg, cfg.swiper_path)
|
||||
cfg = cfgmod.Cafe24FtpConfig(host="h", port=21, user="u", password="p")
|
||||
content = design_ftp.read_text_file(cfg, path)
|
||||
assert content == "old"
|
||||
|
||||
design_ftp.write_text_file(cfg, cfg.swiper_path, "new content")
|
||||
assert design_ftp.read_text_file(cfg, cfg.swiper_path) == "new content"
|
||||
design_ftp.write_text_file(cfg, path, "new content")
|
||||
assert design_ftp.read_text_file(cfg, path) == "new content"
|
||||
finally:
|
||||
ftplib.FTP = saved
|
||||
|
||||
@@ -749,9 +768,9 @@ def test_design_ftp_missing_file_raises_cafe24_error():
|
||||
saved = ftplib.FTP
|
||||
ftplib.FTP = _FakeFTP
|
||||
try:
|
||||
cfg = cfgmod.Cafe24FtpConfig(host="h", port=21, user="u", password="p", swiper_path="/missing.js")
|
||||
cfg = cfgmod.Cafe24FtpConfig(host="h", port=21, user="u", password="p")
|
||||
try:
|
||||
design_ftp.read_text_file(cfg, cfg.swiper_path)
|
||||
design_ftp.read_text_file(cfg, "/missing.js")
|
||||
raise AssertionError("Cafe24FtpError 가 났어야 한다")
|
||||
except Cafe24FtpError:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user