Files
Aislo/resources/tester/test_m01_logic_source.py
T
eomsangdonandClaude Opus 5.5 7d39f90a0e feat(M01): 단가산출 로직 상세 차례 · 오른쪽 흐름도/원문 두 패널
- 좌측 차례 = 기본정보 › 시험 계산 › 단가산출 상세 › 텍스트 수식
- 오른쪽 패널 둘(흐름도 · 원문) — 하나만 열림 · 둘 다 접기 · 머리 토글 단추 · 열린 패널 계정 취향(m01-logic-panel)
- 흐름도 패널 접힘을 부르는 쪽이 정하는 길(folded · onFold · fold)
- 원문 패널 = 출처 글로 품셈 본문 절을 찾아 보임(GET /api/m01/logic/source) · 못 찾으면 「원문 연결 없음」 + 출처
- 시험 test_m01_logic_source.py · 화면 시나리오 ui_checks/44-4_로직상세_패널.js

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NPJGtfXo6GMbcpiboQC4uK
2026-10-05 11:31:09 +09:00

56 lines
2.2 KiB
Python

"""M01 로직 원문 — 출처 글 → 품셈 본문 절(44-4). 원본은 읽기만."""
from __future__ import annotations
import json
from fastapi import FastAPI
from fastapi.testclient import TestClient
from M01_MasterData import M01_MasterData_Router as router_module
from M01_MasterData import M01_MasterData_Store as store
from M01_MasterData import M01_MasterData_Store_Make as make
def test_build_civil_section_with_table() -> None:
got = make.source("건설품셈 토목 1-1-2")
assert len(got["found"]) == 1
one = got["found"][0]
assert one["matched"] == "1-1-2"
assert one["file"].startswith("원가계산/건설공사_표준품셈/본문/02_토목부문/제01장_")
assert one["blocks"][0]["h"] == 3 and one["blocks"][0]["text"].startswith("1-1-2 유도선")
table = next(b["table"] for b in one["blocks"] if "table" in b)
assert table[0][0] == "구분" and ["특별인부", "인", "2", "1,350", "1,560"] in table
# 다음 절(1-1-3 …) 앞에서 끊김 · 주석 줄 뺌
assert not any("1-1-3" in b.get("text", "") for b in one["blocks"])
assert not any(b.get("p", "").startswith("<!--") for b in one["blocks"])
def test_forest_and_many_numbers() -> None:
forest = make.source("산림품셈 3-4-2 1")["found"]
assert [x["matched"] for x in forest] == ["3-4-2"]
many = make.source("건설품셈 공통 8-1-5 · 8-1-6")["found"]
assert [x["number"] for x in many] == ["8-1-5", "8-1-6"]
def test_no_link() -> None:
assert make.source("현장 자체 단가")["found"] == []
assert make.source("건설품셈 토목 99-9-9")["found"] == []
def test_most_master_logics_link() -> None:
"""정본 로직 출처 대부분이 원문 절에 닿음."""
hit = total = 0
for path in store.FOLDER.glob("로직_*품셈_*.json"):
for row in json.loads(path.read_text(encoding="utf-8"))["줄"]:
total += 1
hit += bool(make.source(row.get("출처", ""))["found"])
assert total > 1000 and hit / total > 0.9, (hit, total)
def test_route() -> None:
app = FastAPI()
app.include_router(router_module.router)
got = TestClient(app).get("/api/m01/logic/source", params={"src": "산림품셈 3-1"}).json()
assert got["found"][0]["matched"] == "3-1"