33 lines
1.6 KiB
Python
33 lines
1.6 KiB
Python
"""EST 테스트 앱 JDLExcel과 단가비교(원본 ActionJDLCompare — Excel 코드 칸이 코드를 품으면 같은 행 합계와 TC 비교)."""
|
|
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def test_compare_contains_code_limit_and_xls_tables():
|
|
code = r"""
|
|
const fs = require('fs'), vm = require('vm');
|
|
const ctx = vm.createContext({});
|
|
vm.runInContext(fs.readFileSync('tools/est-test/native-jdl-compare.js', 'utf8'), ctx);
|
|
const J = vm.runInContext('EstJdlCompare', ctx);
|
|
const rows = [{ Code: 'U001', Name: '가', TC: 1000 }, { Code: 'U002', Name: '나', TC: 500 },
|
|
{ Code: 'U003', Name: '다', TC: 7 }, { Code: '', Name: '머리' }];
|
|
const table = [['코드', '', '합계'], ['[U001] 가', '', '1,000'], ['U002', '', 499]];
|
|
const out = J.compare(rows, table, 0, 2).map((r) => [r.Code, r.OTC, r.GN, r.Checked]);
|
|
const far = Array.from({ length: 60 }, () => ['x']); far.push(['U009', '', 5]);
|
|
const limit = J.compare([{ Code: 'U009', TC: 5 }], far, 0, 2)[0].OTC;
|
|
const xls = J.xlsTables([{ name: 'S1', cells: { '0,0': { value: 'U001' }, '0,7': { value: 1000 }, '2,1': { value: 'b' } } }]);
|
|
process.stdout.write(JSON.stringify({ out, limit, xls: xls.S1 }));
|
|
"""
|
|
out = json.loads(subprocess.check_output(["node", "-e", code], cwd=ROOT).decode("utf-8"))
|
|
assert out["out"] == [
|
|
["U001", 1000, 0, False],
|
|
["U002", 499, 1, True],
|
|
["U003", None, None, True],
|
|
]
|
|
assert out["limit"] is None
|
|
assert out["xls"][0][0] == "U001" and out["xls"][0][7] == 1000 and out["xls"][2][1] == "b"
|