Files
Aislo/resources/tester/test_794_2b_edition.py
T

153 lines
5.9 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.
"""794-2b 지킴 — 품셈 판 표지 · 잔토처리 단독 GC.
① 로직 줄 칸 「개정」 = 빌더(`build_로직_개정.py`)가 원문 절 머리에서 뽑은 값과 같음 · 채움 수.
② 셈 값 그대로 — 791-1 지문 fixture 가 지금 마스터 지문(건너뜀 없이 1,515 전후 같음을 돎).
③ 근거 제안 까닭 판 번호 — 봉화#98 철근 현장조립 3.5 ↔ 3.4 = 「판 차이('24 보완 · 파일 2024)」 ·
거창#28 · 봉화#8 뒤채움 같은 배 ×1.98 = 「판 차이 강함」(엑셀 = `helper_m02_hopyo_golden.FILES`).
④ 잔토처리(인력) GC001194 = ㎥당 보통인부 0.2 인(건설 공통 3-2-1 비고).
"""
import importlib
import json
import helper_m02_hopyo_golden as golden
import pytest
from M01_MasterData import M01_MasterData_Store as m01 # scripts 길을 둠
from M02_MasterTemplete import M02_San_Basis_Check as chk
from M02_MasterTemplete import M02_San_Basis_Store as store
from M02_MasterTemplete import M02_San_Book as san_book
rev = importlib.import_module("build_로직_개정")
mf = importlib.import_module("master_formula")
fp = importlib.import_module("test_791_1_engine_semantics")
def _rows() -> dict:
files, _ = m01.loaded()
return {r["키"]: r for d in files.values() if d.get("그룹") == "로직" for r in d["줄"]}
def test_개정_칸_빌더와_같음():
got = rev.build(check=True)
assert got["바뀐 파일"] == 0 # 마스터 = 빌더 값(손 입력 없음)
assert got["GC 채움"] + got["GF 채움"] >= 1237 and got["GF 빈칸"] == 0
rows = _rows()
assert rows["GC000083"]["개정"] == [2008, 2020, 2025] # 3-2-1('08, '20, 25년 보완)
assert 2024 in rows["GC000207"]["개정"] # 6-2-3 철근 현장조립 '24 보완
assert rows["GF000123"]["개정"] == [2026] # 산림 2026-01-01 제정
cols = list(rows["GC000083"])
assert cols.index("개정") == cols.index("출처") + 1 # _틀.md 7 장 열 차례
def test_셈_지문_건너뜀_없음():
saved = json.loads(fp.FINGER.read_text(encoding="utf-8"))
assert saved["마스터"] == fp._master_hash()
assert len(saved["결과"]) >= 1516
def test_잔토처리_단독():
_, whole = m01.loaded()
row = _rows()["GC001194"]
assert (row["원문번호"], row["결과단위"]) == ("3-2-1", "원/㎥")
raw = mf.run(whole, "GC001194", {})
(line,) = raw["줄"]
assert (line["이름"], float(line["수량"])) == ("보통인부", 0.2)
def test_연도_읽기():
assert [chk.file_year(p.name) for p in golden.FILES.values()] == [
2026,
2026,
2025,
2024,
2024,
2024,
2025,
2025,
]
assert chk.text_year({"글": ["2017년 품셈 6-3-1"]}) == 2017
assert chk.text_year({"글": ["「24년 건설표준품셈 6-2-3」"]}) == 2024
assert chk.text_year({"글": ["건설표준품셈 6-2(철근) 적용"]}) is None
assert chk.edition_tag("GC000207", [2008, 2014, 2022, 2024], 2024, "파일") == (
"'24 보완 · 파일 2024"
)
assert chk.edition_tag("GC000211", [2017, 2018], 2017, "글") == "'18 보완 · 글 2017"
assert chk.edition_tag("GF000123", [2026], 2026, "글") == ""
def test_판_차이_강함_틀():
a = {
"1": {
"근거후보": [
{
"기초": "GC1",
"판": "'25 보완 · 파일 2024",
"까닭": [["그 밖", "보통인부 ×1.98"], ["단위 기준 차이", "x ×10"]],
}
]
}
}
b = {
"9": {
"근거후보": [
{"기초": "GC1", "판": "'25 보완 · 파일 2025", "까닭": [["그 밖", "보통인부 ×1.99"]]}
]
}
}
got = chk.strong(a, [b])["1"]["근거후보"][0]["까닭"]
assert got == [
["판 차이 강함('25 보완 · 파일 2024)", "보통인부 ×1.98"],
["단위 기준 차이", "x ×10"],
]
assert chk.strong(a, [])["1"]["근거후보"][0]["까닭"][0][0] == "그 밖"
assert a["1"]["근거후보"][0]["까닭"][0][0] == "그 밖" # 저장본 안 고침
def _one(tag: str, no: int) -> dict:
path = golden.FILES[tag]
book = golden.read(tag) if path.exists() else None
if book is None:
pytest.skip(f"실무 엑셀 없음 {tag}")
sheets = san_book.sheets(path.name, path.read_bytes()) if book["꼴"] == "STmate" else {}
book = {**book, "숨은식": store.hidden(book, sheets), "파일": path.name}
return store.one(book, no)
def test_봉화98_판_번호():
got = {c["기초"]: c for c in _one("봉화", 98)["근거후보"]}
c = got["GC000207"]
assert c["단"] == "근접" and c["판"] == "'24 보완 · 파일 2024"
assert ["판 차이('24 보완 · 파일 2024)", "철근공 ×0.9714"] in c["까닭"]
def test_뒤채움_두_파일_판_차이_강함():
a, b = _one("봉화", 8), _one("거창", 28)
marks = [
lab for c in chk.strong({"8": a}, [{"28": b}])["8"]["근거후보"] for lab, _ in c["까닭"]
]
assert "판 차이 강함('25 보완 · 파일 2024)" in marks
def test_listing_다른_HP_대조(monkeypatch):
mine = {
"1": {
"근거후보": [
{"기초": "GC1", "판": "'25 보완 · 파일 2024", "까닭": [["그 밖", "보통인부 ×1.98"]]}
]
}
}
other = {
"9": {
"근거후보": [
{"기초": "GC1", "판": "'25 보완 · 파일 2025", "까닭": [["그 밖", "보통인부 ×1.98"]]}
]
}
}
got = {"HP-000001": mine, "HP-000002": other, "HP-000003": None}
monkeypatch.setattr(store, "solved", lambda folder, key: got[key])
monkeypatch.setattr(store.hopyo_store, "rows", lambda folder: [{"키": k} for k in got])
out = store.listing("x", "HP-000001")
assert out["블록"]["1"]["근거후보"][0]["까닭"][0][0] == "판 차이 강함('25 보완 · 파일 2024)"
assert store.block("x", "HP-000001", 1)["근거후보"][0]["까닭"][0][0].startswith("판 차이 강함")