feat(779-1): 격자 세 보기 — 목록표 둘 · 보기 · 원본 · 목록 · 줄 행 대응
- Grid SHEETS 에 단가산출총괄표 · 단가산출근거목록표 추가(탭 차례 일위대가표 · 단가산출표 · 상세)
- 응답에 보기 {역할: 시트 id} · 원본 · 목록 {호표, 단산: [{번, 행}]} · 줄 [{번, 차례, 행, 단산?, 일위?}] 더함(옛 칸 그대로)
- STmate 목록은 숨은 COD 코드로 짝(차례 번 ≠ 블록 번)
- Excel._sheets 에 wanted 인자만(기본 그대로)
- 시험: test_779_grid_views 새로(여덟 파일) · test_m02_hopyo_grid 시트 목록 기대값 세 장으로 고침(탭이 늘어서)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
"""779-1 격자 세 보기 — 여덟 실무 파일: 보기 셋(두 꼴 같은 역할) · 목록 짝 100 % · 줄 행 대응.
|
||||
|
||||
`M02_Hopyo_Grid.read` 응답 `보기 · 원본 · 목록 · 줄` — 서버 몫만(화면 없음).
|
||||
"""
|
||||
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
|
||||
from M02_MasterTemplete import M02_Hopyo_Excel as hx
|
||||
from M02_MasterTemplete import M02_Hopyo_Grid as hg
|
||||
from resources.tester.helper_m02_hopyo_golden import FILES
|
||||
|
||||
warnings.filterwarnings("ignore", category=UserWarning, module="openpyxl")
|
||||
ROLES = {"일위대가표", "단가산출표", "단가산출상세"}
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", params=sorted(FILES))
|
||||
def one(request):
|
||||
path = FILES[request.param]
|
||||
data = path.read_bytes()
|
||||
parsed = hx.read_book(path.name, data)
|
||||
return parsed, hg.read(path.name, data, parsed)
|
||||
|
||||
|
||||
def test_보기_셋(one):
|
||||
parsed, grid = one
|
||||
assert set(grid["보기"]) == set(grid["원본"]) == ROLES
|
||||
names = {s["id"]: s["이름"] for s in grid["책"]["시트"]}
|
||||
assert [names[grid["보기"][r]] for r in ("일위대가표", "단가산출표", "단가산출상세")] == [
|
||||
grid["원본"][r] for r in ("일위대가표", "단가산출표", "단가산출상세")
|
||||
]
|
||||
assert list(names) == [grid["보기"][r] for r in ("일위대가표", "단가산출표", "단가산출상세")]
|
||||
assert len(grid["책"]["시트"]) == 3
|
||||
assert parsed["꼴"] in ("엑셀꼴", "STmate")
|
||||
|
||||
|
||||
def test_목록_짝_100(one):
|
||||
parsed, grid = one
|
||||
for key in ("호표", "단산"):
|
||||
got = grid["목록"][key]
|
||||
assert sorted(x["번"] for x in got) == sorted(x["번"] for x in parsed[key]), key
|
||||
rows = [x["행"] for x in got]
|
||||
assert len(set(rows)) == len(rows) and min(rows) >= 4
|
||||
|
||||
|
||||
def test_줄_행_대응(one):
|
||||
parsed, grid = one
|
||||
lines = [(h["번"], x) for h in parsed["호표"] for x in h["줄"]]
|
||||
assert [(x["번"], x["차례"], x["행"]) for x in grid["줄"]] == [
|
||||
(n, x["차례"], x["행"]) for n, x in lines
|
||||
]
|
||||
span = {h["번"]: h["행"] for h in parsed["호표"]}
|
||||
block = {b["번"]: b["행"] for b in parsed["단산"]}
|
||||
for one_, (no, line) in zip(grid["줄"], lines, strict=True):
|
||||
assert span[no][0] < one_["행"] <= span[no][1]
|
||||
ref = line.get("참조") or {}
|
||||
if ref.get("종류") == "단산" and ref["번"] in block:
|
||||
assert one_["단산"] == {"번": ref["번"], "행": block[ref["번"]]}
|
||||
else:
|
||||
assert "단산" not in one_
|
||||
if ref.get("종류") == "일위" and ref.get("번") in span:
|
||||
assert one_["일위"] == {"번": ref["번"], "행": span[ref["번"]]}
|
||||
else:
|
||||
assert "일위" not in one_
|
||||
assert any("단산" in x for x in grid["줄"])
|
||||
|
||||
|
||||
def test_두_꼴_같은_역할_셋():
|
||||
"""역할마다 엑셀꼴 · STmate 시트 이름 하나씩 · 탭 차례 = 역할 차례(꼴별로)."""
|
||||
assert {r: len(n) for r, n in hg.ROLES.items()} == dict.fromkeys(ROLES, 2)
|
||||
first = [hg.SHEETS.index(n[0]) for n in hg.ROLES.values()]
|
||||
second = [hg.SHEETS.index(n[1]) for n in hg.ROLES.values()]
|
||||
assert first == sorted(first) and second == sorted(second)
|
||||
@@ -38,7 +38,7 @@ def _sheet(grid: dict, name: str) -> dict:
|
||||
def test_격자_모양(north):
|
||||
book = north["책"]
|
||||
assert (book["종류"], book["판"], book["활성"]) == ("통합문서", 1, "s1")
|
||||
assert [s["이름"] for s in book["시트"]] == ["일위대가", "단가산출"]
|
||||
assert [s["이름"] for s in book["시트"]] == ["일위대가", "단가산출총괄표", "단가산출"]
|
||||
sheet = _sheet(north, "일위대가")
|
||||
assert len(sheet["병합"]) == 11 and "B1:O2" in sheet["병합"]
|
||||
assert len(sheet["열"]) == 15 and sheet["열"]["C"]["폭"] == round(7208 / 256, 2)
|
||||
@@ -143,7 +143,11 @@ def test_STmate_격자():
|
||||
data = path.read_bytes()
|
||||
parsed = hx.read_book(path.name, data)
|
||||
grid = hg.read(path.name, data, parsed)
|
||||
assert [s["이름"] for s in grid["책"]["시트"]] == ["일위대가표", "단가산출근거"]
|
||||
assert [s["이름"] for s in grid["책"]["시트"]] == [
|
||||
"일위대가표",
|
||||
"단가산출근거목록표",
|
||||
"단가산출근거",
|
||||
]
|
||||
cells = _sheet(grid, "일위대가표")["칸"]
|
||||
one = grid["호표"][0]
|
||||
assert one == {"번": 1, "이름": "녹생토(종자배합)", "행": [5, 10]}
|
||||
|
||||
Reference in New Issue
Block a user