- 로직 줄 구분 칸 · 드롭다운 글 = 일위대가화 · 저장 키 `승격` 그대로 - B09 안내 · 빈 표 글은 155(데스크탑 보조) 몫 — 안 고침 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SE9MxeXTu2uaDZ55BJowAY
104 lines
3.8 KiB
Python
104 lines
3.8 KiB
Python
"""일위대가 로직 줄 단가승격 표시(PLAN 134-1) — 줄에 `승격: true` · 금액 무관.
|
|
|
|
- 서버 `clean` = `true` 만 남김(거짓 · 글 · 참조 줄은 버림) · 저장 왕복에 남음 · 금액 그대로
|
|
- 사전조합 안 로직 줄엔 승격 없음(정리 때 버림)
|
|
- 화면 `normalizeLabor` 도 `true` 만 통과(Node 헬퍼)
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
from M02_MasterTemplete import M02_Labor_Doc as labor
|
|
from M02_MasterTemplete import M02_Labor_Ref as refs
|
|
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
|
from resources.tester.test_m02_structure import write_sample_table
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
NET = "GC000337"
|
|
BARE = "GC000994"
|
|
|
|
|
|
def _doc(lines):
|
|
return {"열": "rv", "담은로직": lines, "자재": []}
|
|
|
|
|
|
def test_clean_은_참만_남김():
|
|
got = labor.clean(_doc([{"로직": NET, "승격": True}, {"로직": BARE, "승격": "yes"}]))[
|
|
"담은로직"
|
|
]
|
|
assert got[0]["승격"] is True and "승격" not in got[1]
|
|
|
|
|
|
def test_승격은_금액을_안_바꿈():
|
|
plain = labor.calc(labor.clean(_doc([{"로직": NET, "수량": {"손": 2}}])), {})
|
|
flag = labor.calc(labor.clean(_doc([{"로직": NET, "수량": {"손": 2}, "승격": True}])), {})
|
|
assert flag["반영합"] == plain["반영합"] and flag["기준합"] == plain["기준합"]
|
|
|
|
|
|
def test_사전조합_안_로직_줄엔_승격_없음(monkeypatch):
|
|
monkeypatch.setattr(refs, "here", lambda: ("system", None))
|
|
lines = refs._combo_lines({"담은로직": [{"로직": NET, "승격": True}]}, "SC-000009")
|
|
assert "승격" not in lines[0]
|
|
|
|
|
|
@pytest.fixture()
|
|
def system(tmp_path, monkeypatch):
|
|
write_sample_table(tmp_path)
|
|
monkeypatch.setattr(store, "FOLDER", tmp_path)
|
|
store.create_structure("rv")
|
|
return tmp_path
|
|
|
|
|
|
def test_저장_왕복에_승격_남음(system):
|
|
have = store.read("labor", "rv")
|
|
sent = {
|
|
**have["문서"],
|
|
"담은로직": [
|
|
{"로직": NET, "수량": None, "승격": True},
|
|
{"로직": BARE, "수량": None},
|
|
],
|
|
}
|
|
store.write("labor", "rv", have["판"], sent)
|
|
rows = store.read("labor", "rv")["문서"]["담은로직"]
|
|
assert rows[0]["승격"] is True and "승격" not in rows[1]
|
|
# 내리면(드롭다운 단가산출) 칸째 사라짐
|
|
have = store.read("labor", "rv")
|
|
store.write("labor", "rv", have["판"], {**have["문서"], "담은로직": [{"로직": NET}]})
|
|
assert "승격" not in store.read("labor", "rv")["문서"]["담은로직"][0]
|
|
|
|
|
|
def test_화면_정리도_참만_통과():
|
|
doc = {
|
|
"담은로직": [
|
|
{"로직": NET, "승격": True},
|
|
{"로직": BARE, "승격": False},
|
|
{"로직": "", "참조": {"층": "system", "주인": None, "키": "SC-000001"}, "승격": True},
|
|
]
|
|
}
|
|
proc = subprocess.run(
|
|
["node", os.path.join(HERE, "helper_m02_labor_normalize.cjs")],
|
|
input=json.dumps({"doc": doc, "column": "rv"}, ensure_ascii=False),
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
check=True,
|
|
)
|
|
rows = json.loads(proc.stdout)["담은로직"]
|
|
assert [r.get("승격") for r in rows] == [True, None, None]
|
|
|
|
|
|
def test_화면_글은_일위대가화_저장_키는_승격():
|
|
"""149-3 — 구분 칸 · 드롭다운 글 = 「일위대가화」 · 저장 키 `승격` 그대로"""
|
|
from pathlib import Path
|
|
|
|
m02 = Path(HERE).parents[1] / "M02_MasterTemplete"
|
|
text = (m02 / "M02_MasterTemplete_Labor_Text.ts").read_text("utf-8")
|
|
assert 'Kind_Promote: ["일위대가화", "Unit-price item"],' in text
|
|
assert "단가승격" not in text
|
|
rows = (m02 / "M02_MasterTemplete_Labor_Rows.ts").read_text("utf-8")
|
|
assert 'tc("Kind_Promote")' in rows
|
|
assert "승격?: boolean;" in (m02 / "M02_MasterTemplete_Labor_Api.ts").read_text("utf-8")
|