코드 - 고정 줄 단가 = M02_Labor_Fixed.line(사본 묶음 · 이은 노임 · 자재 = 묶음 값) — B09 단가 책으로 다시 안 덮음 - 대가 · 산근 고친 칸 = 품만 실제로(단가 칸 덮기 줄 남던 흠 · 품 고친 뒤 줄 금액 다시 셈 흠 py · ts 짝) - 산근 글 = 엔진 단가 셈 그대로 · 별도계상 재료 줄 끝 「· 별도계상 = 0.0」 · 계 줄 = 블록 합 - 노무비 · 중기목록 이름에서 규격 겹침 뗌 · TS 바탕 셈 이름 PARTS → MACHINE_PARTS(짝 시험이 TS 를 이어 붙일 때 겹침) 시험(고친 까닭 = 단가 원천이 B09 책 → M02 엔진 · 노임 · 기계 덮개 · 단가 고친 칸 · 중기사용료 걷음) - 144 바탕 · 뼈대: 운전사 · 중기사용료 · 경비 · 덮개 시험 걷음 → 노무 · 중기 나열 · 사급 표시 · 자재만 책 - 145-1 · 145-2 · 155 · 157-1 · 166-2 · 166-6 · 719-3 · 719-4 · 723-4 · 778-4 · 792-3: 줄 단가 = own(엔진) · 산근 = Solver() · collect 새 부름 꼴 - 702 · 705-1 · 719-2: 단가 칸 덮개 = 안 읽음 · 고정 줄 = M02 셈(노임 새 판 따라가기 시험 걷음) - 203-1 · 296 · 703-3 · 795-4: 단가 책 = 자재 줄로 - 707 · 707-6 · 707-7: 단가표 불러오기 = 자재만 · 거창 이은 안내판 줄 = M02 사본 셈(엑셀 −50,000) - 201-1: 환율 · 중기사용료 표 걷음 · b09 저장 속도: 산근 앞 풀이 그대로(단가 표 같음 견줌 걷음) - 대상 113 파일 764 통과 · 25 실패 = 원래 실패(formatMoney · formatPrice 없음 · 단위 글 ㎜ · sec · 719-1 · 796-2e · 717-4 · 721 · 311 · 243 · 246) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
3.5 KiB
Python
76 lines
3.5 KiB
Python
"""703-3 B09 [업데이트] 한 곳 — 단가 책 다시 굳힘 + 원본이 바뀐 구조물 사본 재적용.
|
|
|
|
- 미리 보기 수(`Refresh.preview`) = 적용 뒤 책 견줌(`Prices.book_diff`) 수 · 노임 판 전 → 후 · 고친 칸 수
|
|
- 재적용 = 연결된 사본 중 원본이 바뀐 것만 · 하나가 막혀도 나머지 · 덮개(사용자 값) 안 건드림
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
if str(ROOT) not in sys.path:
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from B09_Estimation import B09_Estimation_Prices as prices # noqa: E402
|
|
from B09_Estimation import B09_Estimation_Refresh as refresh # noqa: E402
|
|
from B09_Estimation import B09_Estimation_Store as store # noqa: E402
|
|
|
|
#: 841-1 책 = 자재만(노임 키 = 노임 판만 셈) — 원목 · 미송각재 + 작업반장(건설업)
|
|
KEYS = ["MT000401", "MT000338", "LB000001"]
|
|
|
|
|
|
def test_책_견줌_미리보기_수_적용_수_같음(tmp_path, monkeypatch):
|
|
monkeypatch.setattr(refresh, "changed_copies", lambda root: [])
|
|
new = prices.refresh_book(KEYS)
|
|
assert new["labor_edition"] == prices.labor_editions(KEYS) and new["labor_edition"]
|
|
old = json.loads(json.dumps(new))
|
|
old["rows"]["MT000401"] = {**old["rows"]["MT000401"], "prices": {}} # 옛 값
|
|
del old["rows"]["MT000338"] # 새 줄
|
|
old["labor_edition"] = {"건설업": "2025-09-01"}
|
|
cover = {
|
|
"S:a": {"x#0": {"qty": 1, "labor": 2}},
|
|
"K:b": {"@copy": {"from": "S:a"}, "y#0": {"qty": 3}},
|
|
}
|
|
got = refresh.preview(tmp_path, old, KEYS, cover)
|
|
after = prices.refresh_book(KEYS, old)
|
|
diff = prices.book_diff(old, after)
|
|
assert (got["새줄"], got["바뀐줄"]) == (diff["new"], diff["changed"]) == (1, 1)
|
|
assert got["단가줄"] == 2 and got["고친칸"] == 3 and got["사본"] == []
|
|
assert got["노임판"]["전"] == "건설업 2025-09"
|
|
assert got["노임판"]["후"].startswith("건설업 2026")
|
|
old.pop("labor_edition")
|
|
assert refresh.preview(tmp_path, old, KEYS, None)["노임판"]["전"].startswith("굳힌 날 ")
|
|
assert prices.book_diff(after, prices.refresh_book(KEYS, after)) == {"new": 0, "changed": 0}
|
|
assert prices.book_stale(after, KEYS) is None
|
|
|
|
|
|
def test_재적용_원본_바뀐_사본만_막혀도_나머지_덮개_그대로(tmp_path, monkeypatch):
|
|
cover = {"S:a": {"x#0": {"qty": 0.3}}}
|
|
store.write_user(tmp_path, {"daega_cover": cover})
|
|
monkeypatch.setattr(
|
|
refresh,
|
|
"linked_snapshots",
|
|
lambda root: {"p1": {"폴더": "a"}, "p2": {"폴더": "b"}, "p3": {"폴더": "c"}},
|
|
)
|
|
items = [
|
|
{"폴더": "a", "이름": "가", "마스터바뀜": True},
|
|
{"폴더": "b", "이름": "나", "마스터바뀜": False}, # 원본 그대로 = 안 함
|
|
{"폴더": "c", "이름": "다", "마스터바뀜": True},
|
|
{"폴더": "z", "이름": "끊김", "마스터바뀜": True}, # 연결 안 됨 = 안 함
|
|
]
|
|
monkeypatch.setattr(refresh.item_copy, "list_items", lambda root: items)
|
|
calls = []
|
|
|
|
def fake(root, folder, who=None):
|
|
calls.append(folder)
|
|
if folder == "c":
|
|
raise LookupError("원본 층 없음")
|
|
|
|
monkeypatch.setattr(refresh.item_copy, "reapply", fake)
|
|
assert [c["이름"] for c in refresh.changed_copies(tmp_path)] == ["가", "다"]
|
|
got = refresh.reapply_changed(tmp_path)
|
|
assert calls == ["a", "c"]
|
|
assert got == {"다시": ["가"], "막힘": ["다 — 원본 층 없음"]}
|
|
assert store.read_user(tmp_path)["daega_cover"] == cover
|