Files
Aislo/resources/tester/test_est_quantity_format.py
T
eomsangdonandClaude Opus 5.5 bd3d258616 feat(est-test): 수량 항목 끝수 처리 선택
- 원본 수량목록 자리수 메뉴처럼 AUTO·절사·올림·반올림 0~5자리를 항목별로 지정
- 결과 코드와 산출 행 결과 표지를 함께 바꾸고 중복 코드 거부
- 새 항목 코드가 끝수 붙은 코드와 겹치던 오류 수정
- 끝수 변경 작업의 ESTX 저장은 명확한 문구로 거부
- 연결 내역코드 칸 선택 상자가 옆 칸을 덮던 배치 수정

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 14:48:28 +09:00

97 lines
3.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""EST 테스트 앱 수량 항목 끝수 처리(원본 AUTO·절사·올림·반올림 0~5)."""
from test_est_rea_parity import run
SHEET = """const sheet={Code:'N1',Name:'시험',options:{digits:2,roundMode:2},
items:[{Code:'r000000',Name:'가'},{Code:'r000001',Name:'나'}],
rows:[{LineData:' 가 1.2345×1 = \\x121.23\\x12',markers:['r000000']},
{LineData:' 나 2.0001×1 = \\x122\\x12',markers:['r000001']}]};"""
def test_format_renames_item_and_marker_and_changes_result():
result = run(
"math",
"(()=>{"
+ SHEET
+ """
const auto=EstQuantity.calculate(sheet).items[0].GN;
EstQuantity.setResultFormat(sheet,0,3,1);
const up=EstQuantity.calculate(sheet).items[0].GN;
const code=sheet.items[0].Code, marker=sheet.rows[0].markers[0];
EstQuantity.setResultFormat(sheet,0,1,3);
const half=EstQuantity.calculate(sheet).items[0].GN;
EstQuantity.setResultFormat(sheet,0,0);
return {auto,up,code,marker,half,back:sheet.items[0].Code,backMarker:sheet.rows[0].markers[0],
other:sheet.items[1].Code};
})()""",
)
assert result == {
"auto": 1.23,
"up": 1.3,
"code": "r00000031",
"marker": "r00000031",
"half": 1.235,
"back": "r000000",
"backMarker": "r000000",
"other": "r000001",
}
def test_format_rejects_bad_digits_collision_and_unknown_code():
result = run(
"math",
"(()=>{"
+ SHEET
+ """
const out=[];
const t=(fn)=>{try{fn();out.push('ok');}catch(e){out.push(e.message.slice(0,6));}};
t(()=>EstQuantity.setResultFormat(sheet,0,2,6));
sheet.items[1].Code='r00000021'; sheet.rows[1].markers=['r00000021'];
t(()=>EstQuantity.setResultFormat(sheet,0,2,1));
sheet.items.push({Code:'X1'});
t(()=>EstQuantity.setResultFormat(sheet,2,2,1));
return {out,unchanged:sheet.items[0].Code};
})()""",
)
assert result["unchanged"] == "r000000"
assert [m[:2] for m in result["out"]] == ["자리", "같은", "이 "]
def test_new_item_code_skips_base_used_by_formatted_code():
result = run(
"math",
"(()=>{"
+ SHEET
+ """
EstQuantity.setResultFormat(sheet,0,2,3);
return EstQuantity.nextItemCode(sheet);
})()""",
)
assert result == "r000002"
def test_estx_export_refuses_format_change_with_clear_message():
import json
import subprocess
from pathlib import Path
import pytest
source = Path("C:/Dasansoft/Est Plus 2/Data/ProjectData/main.estx")
if not source.exists():
pytest.skip("installed EST main sample unavailable")
root = Path(__file__).resolve().parents[2]
script = """
const fs=require('fs'), path=process.argv[1];
const imp=require('./tools/est-test/import-estx.cjs'), q=require('./tools/est-test/native-quantity.cjs');
const ex=require('./tools/est-test/export-estx.cjs'), p=imp.importEstx(fs.readFileSync(path));
const used=(s,c)=>s.rows.some(r=>(r.markers||[]).includes(c));
const s=p.quantitySheets.find(s=>s.items.some(i=>/^r\d{6}$/.test(i.Code)&&used(s,i.Code)));
q.setResultFormat(s,s.items.findIndex(i=>/^r\d{6}$/.test(i.Code)&&used(s,i.Code)),1,3);
let message='';
try { ex.exportEstx(p); } catch (e) { message=e.message; }
process.stdout.write(JSON.stringify(message));
"""
out = subprocess.check_output(["node", "-e", script, str(source)], cwd=root)
assert json.loads(out.decode("utf-8")).startswith("수량 항목 끝수 처리 변경은 ESTX")