Files
Aislo/resources/tester/test_est_find.py
T
eomsangdonandClaude Opus 5.5 892285843d feat(est-test): 워드형 수량산출서 표 보존과 편집 도구
- 가져오기가 WPT 표를 버리던 결함 고침: 표 줄(칸·수량 표지·수식·세로병합) 보존, 문서 읽기 native-quantity-wpt.cjs 로 분리
- 표 셀 합·수량 지정·병합/분리·표 만들기·표 모양, 문단·그림·쪽 삽입/삭제·품명/규격 지정·공종명칭 입력·테두리선·산출근거 양식
- 수량 불러오기·수량목록보기·선택수량복사·내역서 수량붙여넣기(연결)
- ESTX 저장은 표 줄을 건너 문단만 맞춤, 표·서식 편집은 거부

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 18:35:50 +09:00

80 lines
2.7 KiB
Python

"""EST 테스트 앱 찾기 창: 다음찾기 순서·호표 위치·산출근거 문구."""
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-wpt.cjs",
"native-quantity.cjs",
"native-wonga.js",
"native-engine.js",
"native-find.js",
]
def run_js(code: str):
runner = f"""
const fs = require('fs'), vm = require('vm');
const ctx = vm.createContext({{ structuredClone, console }});
for (const f of {json.dumps(FILES)})
vm.runInContext(fs.readFileSync('tools/est-test/' + f, 'utf8'), ctx, {{ filename: f }});
ctx.project = JSON.parse(fs.readFileSync('tools/est-test/sample.json', 'utf8'));
process.stdout.write(JSON.stringify(vm.runInContext({json.dumps(code)}, ctx)));
"""
out = subprocess.check_output(["node", "-e", runner], cwd=ROOT)
return json.loads(out.decode("utf-8"))
def test_next_walks_matches_in_order_and_stops_at_end():
result = run_js("""(() => {
const rows = [{Name:'터파기'},{Name:'되메우기'},{Name:'잔토 터파기',Size:'백호'},{Name:'포장'}];
const first = EstFind.next(rows, '터파기', 0);
const second = EstFind.next(rows, '터파기', first + 1);
const end = EstFind.next(rows, '터파기', second + 1);
const spec = EstFind.next(rows, '백호', 0);
const loose = EstFind.next(rows, ' 잔토 ', 0);
let empty = '';
try { EstFind.next(rows, ' ', 0); } catch (e) { empty = e.message; }
return {first, second, end, spec, loose, empty};
})()""")
assert result == {
"first": 0,
"second": 2,
"end": -1,
"spec": 2,
"loose": 2,
"empty": "검색어를 입력하세요.",
}
def test_search_reads_cost_line_text_and_skips_previous_values():
result = run_js("""(() => {
const rows = [
{LineData:'\\x0e콘크리트\\x0e \\x13타설\\x13', Name_:'옛이름'},
{Name:'다른 행'}
];
return {
line: EstFind.next(rows, '타설', 0),
old: EstFind.next(rows, '옛이름', 0)
};
})()""")
assert result == {"line": 0, "old": -1}
def test_group_position_for_head_rows():
result = run_js("""(() => {
const rows = project.tables.HeadMainDat;
const titles = rows.map((r, i) => [i, r]).filter(([, r]) => Number(r.Index) > 0);
const [start, title] = titles[1];
const hit = EstFind.groupOf(rows, start + 1);
return {code: hit.code === title.Code, position: hit.position};
})()""")
assert result == {"code": True, "position": 1}