47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
from test_est_rea_parity import run
|
|
|
|
|
|
def test_resource_report_separates_each_work_item_without_changing_aggregate():
|
|
result = run(
|
|
"math",
|
|
"""(()=>{
|
|
const p=EstNative.empty();p.options.SourceRefresh=false;
|
|
p.tables.StuffcDat=[{Code:'M',Name:'material',InputTC:100,ValueIndex:4}];
|
|
p.tables.EstMainDat=[{PkID:1,Code:'M',LinkIndex:5,GN:2,GU:100},{PkID:2,Code:'M',LinkIndex:5,GN:3,GU:100},{LinkIndex:54}];
|
|
return {all:EstResources.calculate(p),split:EstResources.calculate(p,true)};
|
|
})()""",
|
|
)
|
|
assert len(result["all"]["rows"]) == 1
|
|
assert len(result["split"]["rows"]) == 2
|
|
assert (
|
|
sum(r["quantity"] for r in result["split"]["rows"])
|
|
== result["all"]["rows"][0]["quantity"]
|
|
== 5
|
|
)
|
|
assert (
|
|
sum(r["amount"] for r in result["split"]["rows"])
|
|
== result["all"]["rows"][0]["amount"]
|
|
== 500
|
|
)
|
|
|
|
|
|
def test_schedule_dates_ranges_and_weighted_user_progress():
|
|
result = run(
|
|
"math",
|
|
"""(()=>{
|
|
const p=EstNative.empty();p.schedule=[
|
|
{id:'a',Code:'A',Name:'first',start:'2026-11-01',end:'2026-11-05',weight:100,progress:25},
|
|
{id:'b',Code:'B',Name:'second',start:'2026-11-06',end:'2026-11-10',weight:300,progress:50}];
|
|
const valid=EstSchedule.calculate(p),bad=[];
|
|
for(const change of [{start:'2026-02-30'},{progress:101},{weight:-1},{end:'2026-10-01'}]) {
|
|
const q=structuredClone(p);Object.assign(q.schedule[0],change);
|
|
try{EstModel.validate(q);bad.push(false)}catch{bad.push(true)}
|
|
}
|
|
return {valid,bad};
|
|
})()""",
|
|
)
|
|
assert result["valid"]["progress"] == 43.75
|
|
assert result["valid"]["rows"][0]["width"] == 50
|
|
assert result["valid"]["rows"][1]["left"] == 50
|
|
assert result["bad"] == [True] * 4
|