feat(카페24): 품목 진열·판매 멀티쇼핑몰 일괄 맞춤 스크립트

- python -m app.modules.cafe24.sync_variant_flags --shops 3,4 [--apply]
- 옵션 상품 전체의 기본몰(1) 품목 진열·판매를 지정 쇼핑몰에 같은 값으로(다른 값만 PUT)
- 기본 미리보기, BEFORE 줄로 원래 값 출력(되돌리기용), 감사 actor SYNC_SHOPS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 15:31:33 +09:00
parent 9f57f5d15e
commit 8043110197
4 changed files with 151 additions and 0 deletions
+25
View File
@@ -516,6 +516,31 @@ def test_route_09b_display_selling_to_all_shops(monkeypatch):
assert list(resp.json()["shop_failed"]) == ["2"]
def test_sync_variant_flags_script(monkeypatch, capsys):
from app.integrations import cafe24 as integ
from app.integrations.cafe24 import products as cp
from app.modules.cafe24 import sync_variant_flags
no, cafe = _new_product()
created = _create_options(no, ["A", "B"])
a = created["variants"][0]["variant_code"]
before = [dict(v) for v in cafe.variants]
assert req("PUT", f"/cafe24/products/{no}/variants",
json={"rows": [{"variant_code": a, "display": "off"}]}).status_code == 200
cafe.stale_variants = before # 다른 쇼핑몰(과 지연된 GET)은 아직 진열함
monkeypatch.setenv("CAFE24_DB_URL", os.environ["CAFE24_TEST_DB_URL"])
monkeypatch.setattr(integ, "build_cafe24_api", lambda st, **kw: fakes.FakeApi(MULTI))
monkeypatch.setattr(cp, "list_all_products", lambda client: ([{"product_no": no}], False))
cafe.calls.clear()
assert sync_variant_flags.main(["--shops", "3"]) == 0
assert not [c for c in cafe.calls if c[0] == "PUT"] # 미리보기는 쓰지 않음
assert sync_variant_flags.main(["--shops", "3", "--apply"]) == 0
puts = [c[2] for c in cafe.calls if c[0] == "PUT"]
assert puts == [{"shop_no": 3, "requests": [{"variant_code": a, "display": "F"}]}]
assert "BEFORE" in capsys.readouterr().out
def test_route_10_rename_with_lagging_variants_keeps_rows():
no, cafe = _new_product()
created = _create_options(no, ["Black", "Red"])