- M02_Doc_NativeEst.triple: 세 줄 수량 식이 같은지 = repr 로 맞댐(자리 규칙 dict 가 set 에 안 들어가 TypeError — 엑셀 줄은 보인 값이 반올림 자리를 타 원파일에 없던 꼴 · 812-3 끝나 브레인이 맡김) - 엑셀 읽기기: 절 소계 덧셈이 뺀 오타 줄 = 비목 없음(블록 금액도 그래야 맞을 때만) · 세 줄 계 금액 칸 비목 하나 = 옮김 · 소계 61 = 금액 칸 비목 하나 · 「.1」 수 · 총괄표 당초 칸 표지 · STmate 엑셀 줄 금액 · 계 꼬리(검산 줄) - 화면: 가져온 식 규격 칸 꼬리표 = 원파일 · 엑셀 갈림(line_stack_sourced) - 시험: 793_1 지움(옛 EST · STmate 엑셀 글 추정 엔진 · 812_1 골든이 대신) · 793_2_san_emit EST 시험 지움(STmate 남김) · 797_1a 옛 표지 ① ② · 줄 단위 합격 · 표본 밖 수 · 버림1 감시 지움(옛 엔진) · 810_1 (c) 엑셀 엔진 대조 지움 · 793_2 실무 블록 · 793_3b 끝전 = 새 길 · 812_1 금액 엇갈림 없음 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
157 lines
7.7 KiB
Python
157 lines
7.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""793-3b 지킴 — 불러오기 단산 줄 = 가져온 식 단가산출 모달(요구 646 · 647 · 652 갈래 C).
|
|
|
|
- 서버 길 `…/sangeun/from-hopyo` — 올림 때 산근 시트 둠(`실무자료/산근/<HP>.json`) →
|
|
블록 → 793-2a 내보내기 → 793-2 가져온 식 SK(만들 층 · 엑셀 단가 그대로 · 검산 = 엑셀) ·
|
|
같은 내용 = 그 SK 다시 씀 · 산근 없는 옛 HP = 409 · HP 지우면 산근도 지움 ·
|
|
STmate 블록 끝전 = 엑셀 계와 맞는 쪽
|
|
- 화면 소스 — 단가산출 탭 목록 [가져온 식으로 열기](`Hopyo_SheetSk`) · 시트 모달
|
|
(`Sangeun_Detail`) · 머리 판(검산 · [우리 단가로] / [엑셀 단가로] · [원본 글 보기] ·
|
|
[이음 고르기] · 소요량 이음) · 부품 상자만 · 700 줄
|
|
- 809-1 걷음(요구 703) — [우리 기초로 바꾸기] · 근거 세 단 · 입력 필요 · [이 줄에 잇기] · 옮기기 판정 길 없음
|
|
임시 storage(`client` 마당) · M01 원본 그대로.
|
|
"""
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
import helper_m02_hopyo_golden as golden
|
|
import pytest
|
|
|
|
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
|
from M02_MasterTemplete import M02_Sangeun_FromHopyo as fh
|
|
from M02_MasterTemplete import M02_Sangeun_Router as sangeun_router
|
|
from M02_MasterTemplete import M02_Template_Layers as layers
|
|
|
|
# ruff: noqa: F811
|
|
from resources.tester.test_m02_hopyo_excel import _post, client, master_hash # noqa: F401
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
M02 = ROOT / "M02_MasterTemplete"
|
|
API = "/api/m02/layers/personal"
|
|
KEY = "HP-000001"
|
|
MINE = ("Hopyo_Imported", "Hopyo_ImportedPanel", "Hopyo_SheetSk", "Hopyo_View")
|
|
|
|
|
|
def _src(name: str) -> str:
|
|
return (M02 / f"M02_MasterTemplete_{name}.ts").read_text(encoding="utf-8")
|
|
|
|
|
|
def _skcount() -> int:
|
|
folder = layers.personal_dir(7, 42) / "sangeun"
|
|
return len(list(folder.glob("*.json"))) if folder.exists() else 0
|
|
|
|
|
|
def _open(client, no=18):
|
|
body = {"층": "personal", "키": KEY, "번": no}
|
|
return client.post(f"{API}/sangeun/from-hopyo", json=body)
|
|
|
|
|
|
# ── 서버 길 ───────────────────────────────────────────────────────────
|
|
def test_단산_블록_가져온_식_만들기_다시씀_지움(client):
|
|
client.app.include_router(sangeun_router.router)
|
|
before = master_hash()
|
|
assert _post(client).status_code == 200
|
|
folder = layers.personal_dir(7, 42)
|
|
assert fh.has(folder, KEY)
|
|
made = _open(client)
|
|
assert made.status_code == 200, made.text
|
|
got = made.json()
|
|
assert got["이름"].startswith("SK-") and got["다시씀"] is False
|
|
assert got["단가기준"] == "엑셀" and got["검산"]["같음"] is True
|
|
assert round(got["검산"]["셈"]["계"]) == 30369 # 북부청임도 단산18 문양거푸집 = 엑셀
|
|
n = _skcount()
|
|
again = _open(client).json()
|
|
assert again["이름"] == got["이름"] and again["다시씀"] is True and _skcount() == n
|
|
with store.at(folder):
|
|
doc = store.read("sangeun", got["이름"])["문서"]
|
|
assert doc["바탕"] is None and doc["가져온"]["원본"]["엑셀금액"]["계"] == 30369
|
|
ten = _open(client, 10).json() # 야면석소운반 — 근거 기초 제안 없음(809-1 · 요구 703)
|
|
with store.at(folder):
|
|
meta = store.read("sangeun", ten["이름"])["문서"]["가져온"]
|
|
assert meta["로직"] and "근거후보" not in meta
|
|
assert _open(client, 99999).status_code == 404
|
|
fh._path(folder, KEY).unlink() # 산근 없는 옛 HP = 다시 올림
|
|
old = _open(client)
|
|
assert old.status_code == 409 and old.json()["detail"] == fh.RELOAD
|
|
assert _post(client).status_code == 200 and fh.has(
|
|
folder, KEY
|
|
) # 같은 엑셀 다시 올림 = 산근 채움
|
|
assert client.delete(f"{API}/hopyo/{KEY}").status_code == 200
|
|
assert not fh.has(folder, KEY) # HP 지우면 산근도
|
|
assert master_hash() == before
|
|
|
|
|
|
RULES = [("봉화", "D00102", "비목버림"), ("동부청영월", "D00003", "합버림_큰나머지")]
|
|
|
|
|
|
@pytest.mark.parametrize(("tag", "code", "rule"), RULES)
|
|
def test_STmate_끝전_엑셀_계와_맞는_쪽(tag, code, rule):
|
|
"""끝전 = 파일 투표(812-1 `M02_San_Xlsx_Stmate.vote` · 블록 계가 맞는 수가 많은 쪽)."""
|
|
from M02_MasterTemplete import M02_San_Xlsx as sx
|
|
from M02_MasterTemplete import M02_San_Xlsx_Stmate as xs
|
|
|
|
if not golden.FILES[tag].exists():
|
|
pytest.skip(f"실무 엑셀 없음 {tag}")
|
|
path = golden.FILES[tag]
|
|
got = sx.read(path.name, path.read_bytes())
|
|
assert got["옵션"]["SAN_TYP"] == xs.RULE[rule]
|
|
assert any(b["코드"] == code for b in got["산근"])
|
|
|
|
|
|
# ── 화면 소스 ─────────────────────────────────────────────────────────
|
|
def test_단산_줄_길_잇기():
|
|
sk, view = _src("Hopyo_SheetSk"), _src("Hopyo_View")
|
|
assert "openImported({" in sk and "dataset.skOpen" in sk # 단가산출 탭 목록 = 가져온 식 모달
|
|
assert (
|
|
'"/sangeun/from-hopyo"' in view and "openSkEdit(" in view
|
|
) # [수정] 단산 줄 = 수식 탭 모달
|
|
imp = _src("Hopyo_Imported")
|
|
assert '"/sangeun/from-hopyo"' in imp and "/sangeun/imported/${how}" in imp
|
|
assert "mountSangeunDetail(" in imp and "saveTemplate(" in imp and "openModal({" in imp
|
|
for how in ('run("price"', 'run("link"'):
|
|
assert how in imp, how
|
|
for gone in ("to-base", "toBase", "onLink", "skPick", "checkJudge", "readJudgeBlock"):
|
|
assert gone not in imp, gone # 809-1 · 요구 703
|
|
# 옛 M02 수식 나무 화면(「엑셀 원래」 위 줄) 걷음 — 수식 탭 = 공용 수식 문서 화면(802-4b-2)
|
|
assert not (M02 / "M02_MasterTemplete_Sangeun_Equation.ts").exists()
|
|
|
|
|
|
def test_머리_판_기초_없음():
|
|
panel = _src("Hopyo_ImportedPanel")
|
|
for word in ("ToOurs", "ToExcel", "Source", "Link", "Same", "Diff"):
|
|
assert f'tx("{word}")' in panel, word
|
|
for gone in ("ToBase", "PickBase", "data-basis-tiers", "우리 기초로 바꾸기", "근거 제안"):
|
|
assert gone not in panel, gone
|
|
model = (M02 / "logic/M02_Hopyo_Imported_Model.ts").read_text(encoding="utf-8")
|
|
assert "BasisCand" not in model and "skPick" not in model and "근거후보" not in model
|
|
assert not re.search(r"from \"@ui|document\.|fetch\(|sessionStorage\.", model) # 순수
|
|
|
|
|
|
def test_부품상자만_700줄_공용_안_고침():
|
|
for name in MINE:
|
|
text = _src(name)
|
|
assert len(text.splitlines()) <= 700, name
|
|
assert not re.search(r"""\bel\(\s*["'](button|input|select)["']""", text), name
|
|
assert not re.search(r"""createElement\(\s*["'](button|input|select)["']""", text), name
|
|
assert "#" not in "".join(re.findall(r"color:\s*[^;]+", text)), name
|
|
for name in ("Labor_Rows", "Labor_SkEdit", "Sangeun_Detail", "Sangeun_Tabs"):
|
|
assert "Hopyo_Imported" not in _src(name), name # 공용 쪽은 새 모달을 모름
|
|
|
|
|
|
def test_가져온_식_시트_M01바뀜_없음(client):
|
|
"""가져온 식 SK 는 M01 짝이 없음 — 저장 M01판이 있어도 시트 「M01 바뀜」 · 짝잃음 안 띄움."""
|
|
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
|
|
|
client.app.include_router(sangeun_router.router)
|
|
assert _post(client).status_code == 200
|
|
name = _open(client).json()["이름"]
|
|
folder = layers.personal_dir(7, 42)
|
|
with store.at(folder):
|
|
doc = store.read("sangeun", name)["문서"]
|
|
spots = list(calc.calc_doc(doc)["시트"]["자리"])
|
|
ans = calc.calc_doc({**doc, "M01판": {k: "다름" for k in [*spots, "x"]}})
|
|
sheet = ans["시트"]
|
|
assert sheet["자리"] and not any(x["M01바뀜"] for x in sheet["자리"].values())
|
|
assert sheet["짝잃음"] == []
|