Merge remote-tracking branch 'origin/main_laptop_1' into sub_laptop_4
This commit is contained in:
@@ -230,10 +230,13 @@ def test_다른_로직_상자는_출력_단위를_따르고_빼면_변수로_돌
|
||||
assert box["unit"] == "㎥/시간"
|
||||
assert call("pillNames", box) == ["작업량"]
|
||||
lg["links"] = [
|
||||
{"id": "l1", "from": {"box": "b1", "name": "작업량"}, "to": {"box": "b2", "name": "x"}}
|
||||
{"id": "l1", "from": {"box": "b1", "name": "작업량"}, "to": {"box": "b2", "name": "x"}},
|
||||
{"id": "l2", "from": {"box": "b2", "name": "관경"}, "to": {"box": "b1", "name": "q"}},
|
||||
{"id": "l3", "from": {"box": "b2", "name": "관경"}, "to": {"box": "b3", "name": "y"}},
|
||||
]
|
||||
back = call("setLogicInput", lg, "b1", None)
|
||||
assert back["boxes"][0]["input"]["mode"] == "variable" and back["links"] == []
|
||||
assert back["boxes"][0]["input"]["mode"] == "variable"
|
||||
assert [x["id"] for x in back["links"]] == ["l3"]
|
||||
assert call("reconcileUnit", lg, "b1") == lg # 다른 로직 상자 단위는 안 건드림
|
||||
|
||||
|
||||
|
||||
@@ -592,3 +592,31 @@ def test_끝수_함수_출력_출력_상자() -> None:
|
||||
"out([a, E.evalLogic(lg, V).cost.노무비]);"
|
||||
)
|
||||
assert got == [537000, 540000]
|
||||
|
||||
|
||||
def test_다_다른_로직_받는_알약_예시값_차례() -> None:
|
||||
got = _run(
|
||||
LOGIC
|
||||
+ "lg = M.updateBox(lg, other.id, { input: { ...lg.boxes[1].input, logic: { ...lg.boxes[1].input.logic, examples: { 계수: 10, 면적: 99 } } } });\n"
|
||||
"const a = E.evalLogic(lg, {}, { logics: LOGICS }).cost.경비;\n"
|
||||
"const b = E.evalLogic(lg, { [other.id]: { 계수: 2 } }, { logics: LOGICS }).cost.경비;\n"
|
||||
"const noEx = M.updateBox(lg, other.id, { input: { ...lg.boxes[1].input, logic: { ...lg.boxes[1].input.logic, examples: undefined } } });\n"
|
||||
"out([a, b, E.evalLogic(noEx, {}, { logics: LOGICS }).cost.경비,"
|
||||
" M.designInputs(lg).map(d => [d.kind, d.port, d.example]), M.designInputs(noEx).map(d => d.example)]);"
|
||||
)
|
||||
a, b, c, designs, plain = got
|
||||
# 면적 = 이어진 선(길이 7) > 예시값 99 · 계수 = 상자 예시값 10 · 넘긴 값 2 가 이김 · 없으면 그 로직 예시값 3
|
||||
assert (a, b, c) == (70000, 14000, 21000)
|
||||
assert designs == [["변수", "길이", 7], ["다른 로직", "계수", 10]]
|
||||
assert plain == [7, None]
|
||||
|
||||
|
||||
def test_표_범위칸_숫자하나는_같음() -> None:
|
||||
got = _run(
|
||||
RULE
|
||||
+ "const T = [['높이·아래', '높이·위', '석공'], [4, 4, 0.5], [4, 6, 0.6], [null, 3, 0.4]];\n"
|
||||
"const rule = { kind: 'lookup', conds: [{ col: '높이', from: { box: 'b1', name: '높이' } }], col: '석공' };\n"
|
||||
"out([4, 5, 2, 3.5, 6].map(h => { const r = R.applyRule(rule, T, { 높이: h }); return [r.value, r.why]; }));"
|
||||
)
|
||||
# 4 = 「4」 줄만(같음) · 4 는 「4~6」(초과) 에 안 듦 · 빈 아래 끝은 열림
|
||||
assert got == [[0.5, None], [0.6, None], [0.4, None], [None, "표에 없는 조건"], [0.6, None]]
|
||||
|
||||
@@ -337,18 +337,15 @@ def _run(lg: dict, master, examples: dict | None = None) -> dict:
|
||||
|
||||
|
||||
def test_값_메쌓기_value_는_calc_와_같음(master) -> None:
|
||||
from M01_MasterData.LogicBuilder import M01_LB_Calc as lb
|
||||
from M01_MasterData import M01_MasterData_Store as store
|
||||
|
||||
_, files = master
|
||||
rows = {r["키"]: r for d in files.values() if d.get("그룹") == "로직" for r in d["줄"]}
|
||||
raw = lambda k: json.loads(json.dumps(rows[k], default=_plain)) # noqa: E731
|
||||
given = {v["name"]: v["example"] for v in SAMPLES["masonry"]["boxes"][0]["input"]["variables"]}
|
||||
want = lb.calc(raw("GF000219"), {**given, "초과증가율": 80}, {})
|
||||
want = store.calc("GF000219", {**given, "초과증가율": 80})
|
||||
assert abs(_run(SAMPLES["masonry"], master)["노무비"] - float(want["sums"]["계"])) < 1
|
||||
given = {v["name"]: v["example"] for v in SAMPLES["value"]["boxes"][0]["input"]["variables"]}
|
||||
given["qt"] = given.pop("q")
|
||||
assert _run(SAMPLES["value"], master)["시간당 작업량"] == float(
|
||||
lb.calc(raw("GF000133"), given, {})["result"]
|
||||
store.calc("GF000133", given)["result"]
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -143,3 +143,15 @@ def test_standardsList_목록() -> None:
|
||||
(1, 0, "버림"),
|
||||
(0.1, 1, "버림"),
|
||||
]
|
||||
|
||||
|
||||
def test_서버_표준_답이_처음_값과_같음() -> None:
|
||||
"""서버(`M02_DF_Values.standards`) 답 = `_standard` 처음 값 · 그 답으로 만든 목록 = 번들 처음 값 목록"""
|
||||
from M02_MasterTemplete.DataFlow import M02_DF_Values as dv
|
||||
|
||||
mine = STD.parent / "_data" / "시험-없는-폴더" # 만들지 않음 — 고친 것 없음 → 처음 값
|
||||
assert not mine.exists()
|
||||
got = dv.standards(STD, mine)
|
||||
assert got == {"unit": UNIT, "money": MONEY, "saved": False}
|
||||
server = _node(f"out(S.standardsList({json.dumps(got, ensure_ascii=False)}));")
|
||||
assert server == _node("out(S.standardsList());")
|
||||
|
||||
Reference in New Issue
Block a user