Files
Aislo/resources/tester/test_719_2_sk_project.py
T
eomsangdonandClaude Opus 5.5 11d348492e refactor(855-F B9-5): 사본 단가산출 굳힘 걷음 — 굳힌 로직 줄(GX9) 대신 M02 문서 + 수식 따로 사본 · B09 대가가 문서 셈
- M02_Item_Sangeun: freeze = SK 마다 지금 M02 셈 사본(Doc_Sk.copy_of · 덮음 반영)을 수식에 따로 · 굳힘 표지로 굳힘 ·
  원본 · 처음 · 덮음바탕(M01 따라옴 기록) 뺌 · 옛 GX9 키 · 굳힌줄 · 정체 · 원본 · SC 굳힌 덮개 줄 지움
  · bundle_keys = SK 셈이 읽는 바탕 로직 · 부름 문서 키 · 값 사본 자원 키 · 가져온 식 줄
- M02_Item_Source: 단가.json 에 로직_단가산출.json(GX9) 없음 · SK 줄은 bundle_keys 로 모음
- B09 Labor_Source.sangeun: SK 대가 블록 = 수식 사본 문서 답(줄 이름 · 단위 · 종류 · 자원 키 · 하위 부름) ·
  셈법(792-4)은 줄이 기초 줄과 맞을 때만 · cid 열쇠 = SK 이름표 · 줄 덮개(패치) = M02 처럼 못 셈
- B09 Linked: sk_answer(사본 SK 문서 셈 · 가져온 식 = 단가기준) · 수요 키 = 셈 기록
- B09 Refresh: 바뀐 SK = SK 문서 · 수식 사본 대조 · Supply.sk_money: 배 = 바탕 줄(바탕 없음 = 1)
- 골든 test_855_b09_golden 다시 뜸 — daega_inputs · 수요 두 갈래만(calc_user · 산근 · 미리보기 · B08 같음):
  SK 블록 origin · cid 열쇠(GX9 → SK 이름표) · 재료 단위 = 문서 표기(kg → ㎏) ·
  따로 고친 SK 줄 수량 = M02 문서(0.018 → 0.036 · 옛 굳힘은 고친 문서를 못 봄) ·
  옛 칸(율 더한줄) SK = M02 처럼 못 셈 → 그 SK 자원 키 둘(LB000038 · EQ000153) 빠짐
- 시험: test_719_1 · 719_2 견본을 수식 사본 있는 SK(M02 에서 고친 문서)로 · 단언을 새 사본 꼴로 ·
  719_2 옛 칸 견본 셋 지움(단가 덮개 · SC 더한줄 펼침 · 내 자료집 둘 — 옛 칸 SK 만들기 = 2-C1 셈 은퇴) ·
  test_778_4 옛 칸 율 더한줄 SK 블록 하나 지움 · test_792_3 ⑤ · test_793_2 = 새 사본 꼴(793_2 우리 단가 = 사본 굳힘)
- 검증: 관련 + 핵심 672 — 통과 671 · test_848_1 ㉦ 하나 = sub4 2-D 굳힘 표지 읽기 두 줄 뒤 통과(브레인 정함) ·
  사본 칸(골든 견본) SK 굳힌줄 · GX9 10 → 0 · 수식 따로 2 → 9 · typecheck 0 · 빌더 --check 같음 · 서버 뜸 로그 오류 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 03:24:52 +09:00

169 lines
7.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""719-2 · 855-F B9-5 공사 쪽 M02 단가산출(SK) — B09 대가 블록 · [재생성](업데이트) · 서고(임시
storage · 실제 M01 읽기만).
- 사본 SK(수식 따로 사본) = 품셈 꼴 대가 블록(`Labor_Source.sangeun`) · 줄 = 문서 답 금액 줄
(M02 에서 고친 문서 그대로) · 금액 = M02 SK 셈
- [재생성] = SK 고친 뒤 다시 굳힘 — cover · cid · 입력값 · 고른자재 · B09 덮개 그대로 ·
덮개 밑 값(base) = 새 단가산출 값 · 서고 사본(`sangeun`)도 원본판 다르면 다시 굳힘
· 미리 보기 SK 줄
(옛 칸 덮개 · 더한줄 SK · 내 자료집 = 옛 칸 SK 만들기는 855 2-C1 셈 은퇴 — 시험 없음)
"""
# ruff: noqa: F811 — 임시 층 fixture `world` 를 들여 씀
import json
import pytest
from B09_Estimation import B09_Estimation_Bill_Library as library
from B09_Estimation import B09_Estimation_Prices as prices
from B09_Estimation import B09_Estimation_Refresh as refresh
from B09_Estimation import B09_Estimation_Sangeun as sangeun
from B09_Estimation.B09_Estimation_Calc_Base import compute_base
from B09_Estimation.B09_Estimation_Calc_Labor import compute_labor
from B09_Estimation.B09_Estimation_Labor_Source import daega_inputs
from B09_Estimation.B09_Estimation_Linked import linked_resource_keys
from M02_MasterTemplete import M02_Item_Copy as item_copy
from M02_MasterTemplete import M02_Item_Snapshot as snapshots
from M02_MasterTemplete import M02_Item_Source as source
from M02_MasterTemplete import M02_Labor_Ref as refs
from M02_MasterTemplete import M02_MasterTemplete_Store as store
from resources.tester.test_145_2_b09_labor_calc import STONE, _item, _project
from resources.tester.test_715_sangeun_store import PCT, _calc, _sk
from resources.tester.test_719_1_sk_freeze import edit
from resources.tester.test_m02_labor_ref import MINE, world # noqa: F401 — 같은 임시 층
TWO_MATS = "GC000565" # 재료 줄 둘(고른자재 열쇠)
OWNER = "7/42"
def _json(value):
return json.loads(json.dumps(value, ensure_ascii=False, default=str))
def _mine(world):
"""SK = 바탕 로직 + M02 에서 고친 문서(따로 · 첫 줄 수량 × 2)."""
key = _sk(world["personal"], 바탕={"로직": PCT})
edit(world["personal"], key)
return key
def _b09(root, cover=None):
keys = linked_resource_keys(root)
inputs = prices.build_inputs(None, keys)
inputs["daega"] = daega_inputs(root)
base = compute_base(inputs, {})
sg = sangeun.build(root, base)
rows = {r["key"]: r for r in sg["sg_list"]}
out = compute_labor(inputs["daega"], base, rows, cover)
return inputs["daega"], {b["id"]: b for b in out["daega_blocks"]}, rows
def _lib(world, tmp_path, key, kind="sangeun"):
root = _project(tmp_path / "proj", [])
made = library.import_copy(root, kind, "personal", OWNER, key)
return root, made["폴더"]
def _same_money(block, live):
assert block["sum"] == pytest.approx(float(live["1단위"]["계"]), abs=5) # 끝수(내림)만 다름
for part, name in (("labor", "노무비"), ("material", "재료비"), ("expense", "경비")):
assert block[part] == pytest.approx(float(live["1단위"][name]), abs=3)
def test_SK_대가_블록_금액_M02_같음(world, tmp_path):
key = _mine(world)
live = _calc(world["personal"], key)
assert not live.get("까닭") and live["1단위"]["계"] > 0
root, folder = _lib(world, tmp_path, key)
daega, done, _ = _b09(root)
block = done[daega["libs"][folder]]
assert block["cover"].startswith("P:") and block["kind"] == "품셈"
lines = block["lines"]
assert all(ln.get("sk") for ln in lines)
assert lines[0]["kind"] == "labor" and lines[0]["key"] == "LB000036"
assert lines[0]["qty"] == pytest.approx(0.036) # M02 에서 고친 문서 = 품셈 0.018 × 2
assert lines[-1]["kind"] == "pct" and lines[-1]["base"] == "part:labor"
_same_money(block, live)
def test_구조물_사본_SK_줄_재생성_덮개_입력값_고른자재_그대로(world, tmp_path, monkeypatch):
key = _mine(world)
ref = {**MINE, "키": key}
with store.at(world["personal"]):
from M02_MasterTemplete import M02_Labor_Doc as labor
doc = labor.clean(
{
"열": "rv",
"담은로직": [
{"참조": ref, "수량": {"손": 2}},
{"로직": "GF000219", "입력값": {}, "수량": {"손": 1}},
{"로직": TWO_MATS, "수량": {"손": 1}},
],
}
)
def build(_item_): # 원본 층 → 사본 파일(구조물 원본 대신 이 일위대가 문서)
rows = source.labor_doc_rows(doc)
return _json(
{
source.LABOR_FILE: rows,
source.PRICE_FILE: source.price_bundle(rows, world["personal"]),
snapshots.VALUES_FILE: {},
}
)
monkeypatch.setattr(item_copy, "build_snapshot", build)
root = _project(tmp_path / "proj", [(100, "SS000901")])
folder = snapshots.structures_dir(root) / snapshots.folder_name("pipe@100.0")
folder.mkdir(parents=True)
values = {"GF000219": {k: {"값": v} for k, v in STONE.items()}}
picks = {TWO_MATS: {"1": "MT000001"}}
for name, data in {
**build(None),
snapshots.VALUES_FILE: values,
snapshots.PICKS_FILE: picks,
snapshots.MANIFEST_NAME: {"원본": {**_item("SS000901"), "경로": ["x"]}},
}.items():
(folder / name).write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8")
rid = refs.ref_id(ref)
was = json.loads((folder / source.LABOR_FILE).read_text("utf-8"))["참조사본"][rid]
daega, _, _ = _b09(root)
combo = next(b for b in daega["blocks"] if b["id"] == daega["owners"]["pipe@100.0"])
sk_block = next(b for b in daega["blocks"] if b["id"] == combo["lines"][0]["key"])
cid = sk_block["lines"][0]["cid"]
cover = {sk_block["cover"]: {cid: {"qty": 0.9}}}
# SK 고침(품 × 2 → × 2 × 3) → [재적용](재생성) = 수식 사본 다시 굳힘
edit(world["personal"], key, 3)
item_copy.reapply(root, folder.name)
after = json.loads((folder / source.LABOR_FILE).read_text("utf-8"))["참조사본"][rid]
assert after["수식"]["문서"] != was["수식"]["문서"] and after["수식"]["따로"]
assert (
json.loads((folder / snapshots.VALUES_FILE).read_text("utf-8"))["GF000219"]
== (values["GF000219"])
)
assert json.loads((folder / snapshots.PICKS_FILE).read_text("utf-8")) == picks
daega2, done, _ = _b09(root, cover)
block = next(b for b in done.values() if b["cover"] == sk_block["cover"])
line = block["lines"][0]
assert line["cid"] == cid and line["covered"] == ["qty"] and line["qty"] == 0.9
assert line["base"]["qty"] == pytest.approx(0.108) # 덮개 밑 = 새 단가산출 값(0.018 × 6)
assert daega2["owners"]["pipe@100.0"] in done
def test_서고_SK_업데이트_미리보기_다시_굳힘(world, tmp_path):
key = _mine(world)
root, folder = _lib(world, tmp_path, key)
assert library.changed(root) == []
before = daega_inputs(root)
cover_key = next(b for b in before["blocks"] if b["id"] == before["libs"][folder])["cover"]
edit(world["personal"], key, 3)
got = refresh.preview(root, None, [], None)
assert [(x["키"], x["판"]) for x in got["단가산출"]] == [(key, "바뀜")]
assert [c["폴더"] for c in got["사본"]] == [folder]
assert refresh.reapply_changed(root)["다시"] == ["내 단가산출"]
assert library.changed(root) == [] and [f.name for f, _ in library.copies(root)] == [folder]
after = daega_inputs(root)
block = next(b for b in after["blocks"] if b["id"] == after["libs"][folder])
assert block["cover"] == cover_key and block["lines"][0]["qty"] == pytest.approx(0.108)