Files
Aislo/resources/tester/test_est_print_batch.py
T
eomsangdonandClaude Opus 5.5 fea0c4aa77 feat(est-test): 묶음 인쇄와 간지
- 원본 처리 근거대로 인쇄표 차례·고른 서식을 한 문서로 이어 인쇄
- 서식마다 간지(제목 가운데·겹테두리), 공사별 선택 저장

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 21:05:42 +09:00

60 lines
2.5 KiB
Python

"""EST 테스트 앱 묶음 인쇄·간지(원본 TEstPrint.Print 0x10fef98 — Checked 서식 차례, 간지 = 가운데 제목)."""
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
FILES = [
"native-math.js",
"native-formula.js",
"native-machine.js",
"native-rows.js",
"native-text.js",
"native-quantity.cjs",
"native-wonga.js",
"native-engine.js",
"native-row-match.js",
"native-escalation.js",
"native-progress.js",
"native-business.js",
"native-review.js",
"native-resources.js",
"native-schedule.js",
"native-model.js",
"native-verify.js",
"native-docs.js",
"native-forms.js",
"native-print-batch.js",
]
def test_checked_forms_in_order_with_gangi():
runner = f"""
const fs = require('fs'), vm = require('vm');
const ctx = vm.createContext({{ structuredClone, console, Intl }});
for (const f of {json.dumps(FILES)})
vm.runInContext(fs.readFileSync('tools/est-test/' + f, 'utf8'), ctx, {{ filename: f }});
ctx.source = JSON.parse(fs.readFileSync('tools/est-test/sample.json', 'utf8'));
ctx.catalog = JSON.parse(fs.readFileSync('tools/est-test/print-catalog.json', 'utf8'));
process.stdout.write(JSON.stringify(vm.runInContext(`(() => {{
const p = EstNative.calculate(EstModel.validate(structuredClone(source)));
const list = EstPrintBatch.forms(catalog, p);
const pick = list.map((f) => ({{ ...f, checked: [9, 8, 1].includes(Number(f.Index)) }}));
const out = EstPrintBatch.document(pick, p, {{ view: 'EstMainDat' }}, true);
const order = [...out.html.matchAll(/<section class="(gangi[^"]*|form)">(?:<div>|<h2>)([^<]*)/g)].map((m) => m[1].split(' ')[0] + ':' + m[2]);
p.printBatch = {{ checked: [9], gangi: false }};
const saved = EstPrintBatch.forms(catalog, p).filter((f) => f.checked).map((f) => f.Index);
return {{ zero: list.some((f) => Number(f.Index) === 0), order, skipped: out.skipped, saved,
gangiOff: !EstPrintBatch.document(pick, p, {{}}, false).html.includes('class="gangi') }};
}})()`, ctx)));
"""
result = json.loads(subprocess.check_output(["node", "-e", runner], cwd=ROOT).decode("utf-8"))
assert result["zero"] is False
names = [x.split(":")[1] for x in result["order"]]
kinds = [x.split(":")[0] for x in result["order"]]
assert kinds[:2] == ["gangi", "form"] and names[0] == names[1]
assert len(result["order"]) + 2 * len(result["skipped"]) == 6
assert result["saved"] == [9]
assert result["gangiOff"] is True