44 lines
2.0 KiB
Python
44 lines
2.0 KiB
Python
from test_est_rea_parity import run
|
|
|
|
|
|
def test_data_issues_detect_duplicate_missing_and_mismatched_links_without_modifying_data():
|
|
result = run(
|
|
"math",
|
|
"""(()=>{
|
|
const p=EstNative.empty();p.tables.StuffcDat=[{Code:'A',Name:'sand',Size:'large'},
|
|
{Code:'B',Name:'first'},{Code:'B',Name:'second'}];
|
|
p.tables.HeadMainDat=[{Index:1,Code:'H',Name:'group'},{Index:0,Code:'A',LinkIndex:5,Name:'sand',Size:'large'}];
|
|
p.tables.EstMainDat=[{Code:'A',LinkIndex:5,Name:'stone',Size:'small'},
|
|
{Code:'B',LinkIndex:5,Name:'ambiguous'},{Code:'missing',LinkIndex:5,Name:'missing'},
|
|
{Code:'H',LinkIndex:103,Name:'group'}];
|
|
const before=JSON.stringify(p),issues=EstIssues.scan(p);
|
|
return {issues,same:before===JSON.stringify(p)};
|
|
})()""",
|
|
)
|
|
assert result["same"]
|
|
items = {(row["table"], row["index"], row["message"]) for row in result["issues"]}
|
|
assert ("StuffcDat", 1, "코드 중복") in items
|
|
assert ("StuffcDat", 2, "코드 중복") in items
|
|
assert ("EstMainDat", 0, "연결 품명 차이") in items
|
|
assert ("EstMainDat", 0, "연결 규격 차이") in items
|
|
assert ("EstMainDat", 1, "연결 코드 중복") in items
|
|
assert ("EstMainDat", 2, "연결 자료 없음") in items
|
|
assert len(items) == 6
|
|
|
|
|
|
def test_cost_error_location_requires_unique_group_and_valid_row():
|
|
result = run(
|
|
"math",
|
|
"""(()=>{
|
|
const p=EstNative.empty();
|
|
p.tables.CostMainDat=[{Index:1,Code:'A'}, {Index:0}, {Index:0},
|
|
{Index:1,Code:'B'}, {Index:0}, {Index:1,Code:'B'}, {Index:0}];
|
|
p.calculation={errors:['A:2 bad formula','A:8 invalid row','B:2 duplicate','other error']};
|
|
return EstIssues.scan(p).filter(x=>x.message.includes('formula') ||
|
|
x.message.includes('row') || x.message.includes('duplicate') || x.message==='other error');
|
|
})()""",
|
|
)
|
|
assert result[0]["table"] == "CostMainDat"
|
|
assert result[0]["index"] == 1
|
|
assert all(row["table"] == "" for row in result[1:])
|