138 lines
5.6 KiB
Python
138 lines
5.6 KiB
Python
"""원본 가시설·측량설계 산근에서 발췌한 단위와 설명 열의 계산 시험."""
|
||
|
||
from test_est_rea_parity import run
|
||
|
||
|
||
def test_text_units_and_description_columns_preserve_numeric_assignments():
|
||
result = run(
|
||
"math",
|
||
r"""EstText.calculate([
|
||
{Index:1,Code:'units',LineData:'units'},
|
||
{LineData:' G2 = 3.14 / 4 ×0.105^2 ×1.50M × 2배 = \x120.026\x12 ㎥',Precision:3},
|
||
{LineData:' N = 2 set'},
|
||
{LineData:' 1. 재료비 : D=16mm, 1본당 4.0m'},
|
||
{LineData:' Q = D × N = \x1232\x12'},
|
||
{LineData:' V = G2 × 1000 = \x1226\x12'}
|
||
])""",
|
||
)
|
||
assert result["errors"] == []
|
||
assert result["rows"][1]["TC"] == 0.026
|
||
assert result["rows"][4]["TC"] == 32
|
||
assert result["rows"][5]["TC"] == 26
|
||
|
||
|
||
def test_text_unit_changes_propagate_without_reusing_stored_results():
|
||
result = run(
|
||
"math",
|
||
r"""EstText.calculate([
|
||
{Index:1,Code:'changed',LineData:'changed'},
|
||
{LineData:' N = 3 set'},
|
||
{LineData:' 1. 재료비 : D=25mm, 1본당 4.0m'},
|
||
{LineData:' Q = D × N = \x1232\x12'},
|
||
{LineData:' V = 1.5M × 3배 = \x123\x12',Precision:2}
|
||
])""",
|
||
)
|
||
assert result["errors"] == []
|
||
assert result["rows"][3]["TC"] == 75
|
||
assert result["rows"][4]["TC"] == 4.5
|
||
|
||
|
||
def test_per_set_unicode_millimetres_and_starred_weight_declarations():
|
||
result = run(
|
||
"math",
|
||
r"""EstText.calculate([
|
||
{Index:1,Code:'source_units',LineData:'source_units'},
|
||
{LineData:' * 본당 중량 W = 0.553톤/본*'},
|
||
{LineData:' T = 20㎜ A = 0.95 × 0.95 = \x120.9\x12㎡',Precision:1},
|
||
{LineData:' 재료비 : \x031,690\x03 × 0.005kg/set = \x128.4\x12',SCheck:-2},
|
||
{LineData:' Q = W × T = \x1211.06\x12',Precision:2}
|
||
])""",
|
||
)
|
||
assert result["errors"] == []
|
||
assert result["rows"][2]["TC"] == 0.9
|
||
assert result["rows"][3]["TC"] == 8.4
|
||
assert result["rows"][4]["TC"] == 11.06
|
||
|
||
|
||
def test_parenthesized_volume_and_count_units_recalculate_from_variables():
|
||
result = run(
|
||
"math",
|
||
r"""EstText.calculate([
|
||
{Index:1,Code:'volume',LineData:'volume'},
|
||
{LineData:' A = 80㎡ B = 16㎡'},
|
||
{LineData:' 새끼 : L =0.05m × 4배 × 4번 × 1줄 = \x120.8\x12m',Precision:1},
|
||
{LineData:' 노무비 : \x0358,122\x03 × 0.1 × (A+B)㎥ = 58,122 × 0.1 × (80+16) = \x12557,971.2\x12',SCheck:-1},
|
||
{LineData:' Q = L × (A+B)㎡ = \x1276.8\x12',Precision:1}
|
||
])""",
|
||
)
|
||
assert result["errors"] == []
|
||
assert result["rows"][2]["TC"] == 0.8
|
||
assert result["rows"][3]["TC"] == 557971.2
|
||
assert result["rows"][4]["TC"] == 76.8
|
||
|
||
|
||
def test_quoted_source_conversion_declaration_propagates_changed_value():
|
||
result = run(
|
||
"math",
|
||
r"""[2,3].map(quantity=>EstText.calculate([
|
||
{Index:1,Code:'quote',LineData:'quote'},
|
||
{LineData:` * 중량환산 : 사석기준 'Q1 = ${quantity}.0 톤/㎥'`},
|
||
{LineData:' 노무비 : \x03235,204\x03 ×1.04인×Q1 = 235,204 ×1.04×2 = \x12489,224.3\x12',SCheck:-1}
|
||
]))""",
|
||
)
|
||
assert all(item["errors"] == [] for item in result)
|
||
assert [item["rows"][2]["TC"] for item in result] == [489224.3, 733836.4]
|
||
|
||
|
||
def test_group_sum_accepts_assigned_price_and_refreshes_from_source():
|
||
result = run(
|
||
"math",
|
||
r"""[550,600].map(price=>{
|
||
const p=EstNative.empty();p.options.SourceRefresh=true;
|
||
p.tables.StuffcDat=[{Code:'M',ValueIndex:4,InputTC:price}];
|
||
p.tables.CostMainDat=[
|
||
{Index:1,Code:'C',LineData:'C'},
|
||
{LinkIndex:5,Code:'M',LineData:' \x0ebrick\x0e \x06A\x06\x03550\x03 : 별산'},
|
||
{LinkIndex:62,SCheck:-1,LineData:' \x07A\x07\x1a550\x1a × 5% = \x1227.5\x12'},
|
||
{SCheck:-1,LineData:' \x1a노무비:27\x1a'},
|
||
{SCheck:-5,LineData:' \x1a계:\x1a \x1227\x12'}];
|
||
p.tables.EstMainDat=[{Code:'C',LinkIndex:104,GN:10},{LinkIndex:54}];
|
||
return EstNative.calculate(p);
|
||
})""",
|
||
)
|
||
assert all(item["calculation"]["errors"] == [] for item in result)
|
||
assert [item["tables"]["CostMainDat"][2]["TC"] for item in result] == [27.5, 30]
|
||
assert [item["tables"]["EstMainDat"][0]["TC"] for item in result] == [270, 300]
|
||
|
||
|
||
def test_subtotal_includes_price_only_rows_and_updates_truncated_final_amount():
|
||
result = run(
|
||
"math",
|
||
r"""[1094,2000].map(price=>{
|
||
const p=EstNative.empty();
|
||
p.tables.StuffcDat=[{Code:'T',ValueIndex:4,InputTC:110754},{Code:'H',ValueIndex:4,InputTC:price}];
|
||
p.tables.CostMainDat=[
|
||
{Index:1,Code:'C',LineData:'transport'},
|
||
{Level:2,LineData:'1. 운반 및 하역'},
|
||
{LinkIndex:5,Code:'T',LineData:' \x0etruck\x0e (\x03110,754\x03 ÷12) ×1.5 = \x1213,844.2\x12'},
|
||
{LinkIndex:5,Code:'H',LineData:' \x0eunloading\x0e \x031,094\x03'},
|
||
{LinkIndex:61,SCheck:-3,TC:14938.2,LineData:' 경비소계 : \x0c14,938.2\x0c'},
|
||
{Level:2,LineData:'2. 합계'},
|
||
{Level:-2,SCheck:-3,LineData:' \x1a경비:14,938\x1a'},
|
||
{Level:-2,SCheck:-5,LineData:' \x1a계:\x1a \x1214,938\x12'}];
|
||
p.tables.EstMainDat=[{Code:'C',LinkIndex:104,GN:10},{LinkIndex:54}];
|
||
const first=EstNative.calculate(p),again=EstNative.calculate(first);
|
||
return {first,again};
|
||
})""",
|
||
)
|
||
assert all(item["first"]["calculation"]["errors"] == [] for item in result)
|
||
assert [item["first"]["tables"]["CostMainDat"][4]["TC"] for item in result] == [
|
||
14938.2,
|
||
15844.2,
|
||
]
|
||
for key in ["first", "again"]:
|
||
assert [item[key]["tables"]["EstMainDat"][0]["TC"] for item in result] == [
|
||
149380,
|
||
158440,
|
||
]
|