- Sangeun: 판정 · 확인 몸 = 모든 블록(북부청 임도 49 → 95) · 줄마다 `부름 [호표 번]`([] = 일위대가 밖) · 밖 블록 = 이름 · 단위 블록 것 · 근거 없음 · 없는 번만 404 · 하위 밖 블록(울진소광 492 → 83)은 확인 목록에 함께 = 하위 먼저 - SkUnit: 줄 0 블록 = 판정 「줄 없음」 고를줄 1 → 확인해도 못만듦(빈 SK 없음) - Marks: 블록마다 `부름` · `줄` · `어긋남` = 모든 블록(밖 포함) · 맞춤셈 `판정` 밖 = None 그대로 - 시험 고침(낡은 기대 = 일위대가 안 블록만): 778-5 units 49 → 95(안 49 따로) · 779-2 어긋남 + 밖 4 · 44 · 48 · 77 · 78 · 779-5 줄 칠 모든 블록 · 778-5 excel misses 밖 블록 5 · 새 시험 test_780_1_sangeun_outside(밖 확인 · 빈 블록 · 울진소광 · 여덟 파일 459) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
4.0 KiB
Python
87 lines
4.0 KiB
Python
"""779-5 블록 안 줄 칠(`logic/M02_MasterTemplete_Hopyo_SheetMap.ts` · Node) — 블록 `줄 [[행, 상태, 차]]` →
|
|
출처 행만 칠(이어짐 초록 · 차 있으면 주황 · 후보 파랑 · 못 이음 빨강 · 밖 흐림) · 머리 행 = 가장 나쁜 칠 ·
|
|
목록 행 = 머리와 같음 · 줄 재료 없으면 옛 블록 칠(범위 통째) · 실물(북부청 임도 · 영월) 줄 칠 수 = 단위 줄 수
|
|
(780-1 모든 블록 · 일위대가 밖 포함) ·
|
|
상태 = 줄 잇기(D-2) · 참고 차 = STmate 옛 노임만."""
|
|
|
|
import warnings
|
|
|
|
import pytest
|
|
|
|
from M02_MasterTemplete import M02_Hopyo_Excel as hx
|
|
from M02_MasterTemplete import M02_Hopyo_Grid as hg
|
|
from M02_MasterTemplete import M02_Hopyo_Marks as mk
|
|
from M02_MasterTemplete import M02_Hopyo_Sangeun as sg
|
|
from M02_MasterTemplete import M02_Hopyo_Units as hu
|
|
from resources.tester.helper_m02_hopyo_golden import FILES
|
|
from resources.tester.test_779_4_sheet_map import _node
|
|
|
|
warnings.filterwarnings("ignore", category=UserWarning, module="openpyxl")
|
|
|
|
GRID = {
|
|
"호표": [],
|
|
"단산": [{"번": 1, "행": [10, 20]}, {"번": 2, "행": [21, 30]}],
|
|
"보기": {"일위대가표": "s1", "단가산출표": "s2", "단가산출상세": "s3"},
|
|
"목록": {"호표": [], "단산": [{"번": 1, "행": 5}, {"번": 2, "행": 6}]},
|
|
"줄": [],
|
|
}
|
|
|
|
|
|
def _mark(no, lines=None):
|
|
m = {"번": no, "판정": "맞음", "SK": None, "갈래": None, "못옮김": []}
|
|
return {**m, "줄": lines} if lines is not None else m
|
|
|
|
|
|
def test_줄_칠_머리_가장_나쁨_옛_칠():
|
|
lines = [[12, "이어짐", False], [13, "이어짐", True], [15, "고를 것", False], [16, "밖", False]]
|
|
got = _node({"grid": GRID, "blocks": [_mark(1, lines), _mark(2)]})["paint"]
|
|
detail, listing = got["s3"], got["s2"]
|
|
assert {r: detail[str(r)] for r in (12, 13, 15, 16)} == {
|
|
12: "success",
|
|
13: "warning",
|
|
15: "info",
|
|
16: "muted",
|
|
}
|
|
assert detail["10"] == "info" and listing["5"] == "info" # 머리 · 목록 = 가장 나쁜 줄
|
|
assert [r for r in range(10, 21) if str(r) in detail] == [10, 12, 13, 15, 16] # 줄 행만
|
|
assert all(detail[str(r)] == "success" for r in range(21, 31)) # 줄 재료 없음 = 옛 칠
|
|
worst = _node(
|
|
{"grid": GRID, "blocks": [_mark(1, [[12, "이어짐", False], [14, "못 이음", False]])]}
|
|
)
|
|
assert worst["paint"]["s3"]["10"] == "danger" and worst["paint"]["s3"]["14"] == "danger"
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def units():
|
|
return hu.Units()
|
|
|
|
|
|
@pytest.mark.parametrize("tag", ["북부청임도", "동부청영월"])
|
|
def test_실물_줄_칠_수_단위_줄_수(tag, units):
|
|
path = FILES[tag]
|
|
data = path.read_bytes()
|
|
parsed = hx.read_book(path.name, data)
|
|
grid = hg.read(path.name, data, parsed)
|
|
grid.pop("책")
|
|
blocks, first = sg.calls(parsed)
|
|
assert len(first) < len(blocks) # 일위대가 밖 블록 있음
|
|
marks, want = [], 0
|
|
for no in sorted(blocks):
|
|
lines = mk.lines(blocks[no], units)
|
|
rows = [u["행"] for u in blocks[no]["항목"] if u.get("행") is not None]
|
|
want += len(rows)
|
|
assert [x[0] for x in lines] == rows
|
|
assert all(s in ("이어짐", "고를 것", "못 이음", "밖") for _, s, _ in lines)
|
|
assert all(not d or s == "이어짐" for _, s, d in lines) # 차 = 이어진 줄만
|
|
marks.append(
|
|
{"번": no, "판정": "맞음", "SK": None, "갈래": None, "못옮김": [], "줄": lines}
|
|
)
|
|
detail = _node({"grid": grid, "blocks": marks})["paint"][grid["보기"]["단가산출상세"]]
|
|
heads = {b["행"][0] for b in grid["단산"]}
|
|
unit_rows = {x[0] for m in marks for x in m["줄"]}
|
|
spans = [b["행"] for b in grid["단산"] if any(x["번"] == b["번"] and x["줄"] for x in marks)]
|
|
painted = {int(r) for r in detail if any(x <= int(r) <= y for x, y in spans)} - heads
|
|
assert unit_rows - heads == painted and want == sum(len(m["줄"]) for m in marks)
|
|
diff = sum(d for m in marks for _, _, d in m["줄"])
|
|
assert (diff > 0) == (tag == "동부청영월") # STmate = 옛 해 노임 · EST = 지금 노임
|