50 lines
2.3 KiB
Python
50 lines
2.3 KiB
Python
from test_est_rea_parity import run
|
|
|
|
|
|
def test_standard_changes_include_new_deleted_and_changed_link_types():
|
|
result = run(
|
|
"math",
|
|
"""(()=>{
|
|
const p=EstNative.empty();p.tables.EstMainDat=[
|
|
{PkID:1,Code:'A',Name:'changed',LinkIndex:21,GN:2,TC:200},
|
|
{PkID:2,Code:'B',Name:'changed link',LinkIndex:5,GN:1,TC:50},
|
|
{PkID:4,Code:'D',Name:'new',LinkIndex:21,GN:1,TC:40}];
|
|
p.baseline={tables:{EstMainDat:[
|
|
{PkID:1,Code:'A',Name:'changed',LinkIndex:21,GN:1,TC:100},
|
|
{PkID:2,Code:'B',Name:'changed link',LinkIndex:21,GN:1,TC:50},
|
|
{PkID:3,Code:'C',Name:'deleted',LinkIndex:21,GN:3,TC:300},
|
|
{PkID:5,Code:'E',Name:'other',LinkIndex:5,GN:1,TC:10}]}};
|
|
return {rows:EstStandard.changes(p),print:EstForms.data('standard-change',p)};
|
|
})()""",
|
|
)
|
|
rows = {row["Code"]: row for row in result["rows"]}
|
|
assert set(rows) == {"A", "B", "C", "D"}
|
|
assert rows["A"]["difference"] == 100
|
|
assert rows["B"]["status"] == "변경"
|
|
assert rows["C"]["status"] == "삭제" and rows["C"]["index"] is None
|
|
assert rows["D"]["status"] == "신규"
|
|
assert result["print"]["rows"] == result["rows"]
|
|
|
|
|
|
def test_standard_usage_reports_applied_and_source_prices_without_mutation():
|
|
result = run(
|
|
"math",
|
|
"""(()=>{
|
|
const p=EstNative.empty();p.tables.SilJukDat=[{Code:'A',Name:'source',ValueIndex:4,InputTC:120},
|
|
{Code:'B',ValueIndex:4,InputTC:50},{Code:'B',ValueIndex:4,InputTC:60}];
|
|
p.tables.EstMainDat=[{Code:'A',Name:'work',LinkIndex:21,GN:2,TU:100,TC:200},
|
|
{Code:'B',Name:'duplicate',LinkIndex:21,GN:1,TU:45,TC:45},
|
|
{Code:'C',Name:'missing',LinkIndex:21,GN:1,TU:20,TC:20},
|
|
{Code:'A',Name:'material',LinkIndex:5,GN:1,TU:10}];
|
|
const before=JSON.stringify(p), rows=EstStandard.usage(p), print=EstForms.data('standard-usage',p);
|
|
return {rows,print,same:before===JSON.stringify(p)};
|
|
})()""",
|
|
)
|
|
assert result["same"]
|
|
assert [row["status"] for row in result["rows"]] == ["연결됨", "코드 중복", "연결 없음"]
|
|
assert result["rows"][0]["sourcePrice"] == 120
|
|
assert result["rows"][0]["appliedPrice"] == 100
|
|
assert result["rows"][0]["difference"] == -20
|
|
assert result["rows"][1]["sourcePrice"] is None
|
|
assert result["print"]["rows"] == result["rows"]
|