Files
Aislo/resources/tester/test_m02_hopyo_draft_calc.py
T
eomsangdonandClaude Opus 5.5 dd49b554b4 feat(M02): 359-3 실무자료 확인 창 표 = 일위대가 상세 꼴 · 금액 미리 셈 · 드롭다운 추가 · 로직없음 · 사용안함
- 줄 표 = 로직 표(차례 · 구분 · 이름 · 별칭 · 수량산출 · 결과 단위 · 노무비 · 재료비 · 경비 · 합계) + 자재 표(세 칸 · 가격 다섯) + 품 비교 · 단추
- 금액 칸 = 위 엑셀 · 아래 우리(줄마다 서버 calc 미리 셈 · 저장 안 함 · 최신 응답만)
- 미리 셈 문서 꼴 = logic/M02_MasterTemplete_Hopyo_Draft.ts(정본 = M02_Hopyo_Build · 수량 = 엑셀 × 배 · 별도계상)
- 드롭다운 글 추가 · 로직없음 · 사용안함(저장 값 그대로) · [엑셀에서 보기] → [엑셀 보기] · [사전조합 생성]
- Check.ts 쪼갬(표 그리기 = Hopyo_CheckRows.ts) · 쓰지 않는 [← 호표 목록] 지움
- 시험 test_m02_hopyo_draft_calc(북부청 실물 줄 → calc 200 · 반영합 · 저장 안 함)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
2026-10-16 20:52:22 +09:00

66 lines
2.8 KiB
Python

"""확인 창 금액 미리 셈 이음매(PLAN 359-3) — 북부청 실물 호표 줄 → 화면 문서 꼴
(`logic/M02_MasterTemplete_Hopyo_Draft.ts` · Node) → 서버 `/labor/{열}/calc`(저장 안 함).
체크 제안 로직 줄(제1~10호표) = 200 · 반영합 있음 · 우리 수량 = 엑셀 수량 × 배 ·
자재 줄 = 자재 표 · 셈 뒤 층 폴더에 문서 안 생김.
"""
import json
import os
import subprocess
from M02_MasterTemplete import M02_Hopyo_Fit as fit
from M02_MasterTemplete import M02_Template_Layers as layers
from resources.tester import test_m02_hopyo_excel as base
from resources.tester.test_m02_hopyo_excel import _post
HERE = os.path.dirname(os.path.abspath(__file__))
client = base.client # 공용 고정물(임시 층)
CALC = "/api/m02/layers/personal/labor/hopyo-draft/calc"
def _drafts(lines: list[dict]) -> list[dict]:
proc = subprocess.run(
["node", os.path.join(HERE, "helper_m02_hopyo_check.cjs")],
input=json.dumps({"drafts": lines}, ensure_ascii=False),
capture_output=True,
text=True,
encoding="utf-8",
check=False,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
def test_실물_줄_미리_셈(client):
assert _post(client).status_code == 200
folder = layers.personal_dir(7, 42)
fit.run_job(folder, "HP-000001") # 셈 끝(338 숫자 판정)
before = sorted(p.name for p in folder.rglob("*") if p.is_file())
lines = [
{**line, "차례": no * 1000 + line["차례"]} # 호표 여럿 줄 한 번에(차례 = 열쇠만)
for no in range(1, 11)
for line in client.get(f"/api/m02/layers/personal/hopyo/HP-000001/{no}").json()["호표"][
"줄"
]
]
drafts = {x["차례"]: x for x in _drafts(lines)}
sure = [x for x in lines if x["맞춤"]["체크"] and any("로직" in p for p in x["맞춤"]["대상"])]
assert len(sure) >= 5, [x["맞춤"]["상태"] for x in lines]
for line in sure:
draft = drafts[line["차례"]]
assert draft["doc"] is not None, line["이름"]
res = client.post(CALC, json={"doc": draft["doc"], "수량": {}})
assert res.status_code == 200, (line["이름"], res.text)
got = res.json()
if draft["table"] == "logic":
row = draft["doc"]["담은로직"][0]
part = line["맞춤"]["대상"][0]
assert row["수량"]["손"] == line["수량"] * part["배"]
assert got["반영합"]["계"] > 0, line["이름"]
for line in lines: # 자재 · 별도계상 줄(대상 없음) = 자재 표
if line["갈래"] in ("자재", "별도계상") and not line["맞춤"]["대상"]:
assert drafts[line["차례"]]["table"] == "mat"
after = sorted(p.name for p in folder.rglob("*") if p.is_file())
assert after == before # 미리 셈 = 저장 안 함