Merge branch 'sub_laptop_8' of C:/Aislo_wt/sub_laptop_8 into main_laptop_1

This commit is contained in:
2026-11-17 19:44:41 +09:00
14 changed files with 338 additions and 138 deletions
+10 -2
View File
@@ -3243,8 +3243,16 @@
"블록 엑셀:울진소광#918": "494eacf70e3fb96f"
},
"올림": {
"올림 2016사방 올림": "591a8b4dfbe67819",
"올림 2026수목 올림": "591a8b4dfbe67819",
"올림 2016사방 고정": "4f53cda18c2baa0c",
"올림 2016사방 목록": "128c3c95d0fb34e1",
"올림 2016사방 올림": "bd033d8606e78695",
"올림 2016사방 재료": "4f53cda18c2baa0c",
"올림 2016사방 칠": "0246368daa0544d7",
"올림 2026수목 고정": "4f53cda18c2baa0c",
"올림 2026수목 목록": "128c3c95d0fb34e1",
"올림 2026수목 올림": "bd033d8606e78695",
"올림 2026수목 재료": "4f53cda18c2baa0c",
"올림 2026수목 칠": "c9e90bcbd1a88642",
"올림 거창 고정": "301f9d50d2aa6e01",
"올림 거창 목록": "1b2914680b1c29fc",
"올림 거창 올림": "5f32212ea5f045b1",
+2 -1
View File
@@ -7,6 +7,7 @@ from pathlib import Path
import openpyxl
from M02_MasterTemplete import M02_Hopyo_Grid as grid
from M02_MasterTemplete import M02_San_Workbook as workbook
ROOT = Path(__file__).parents[2]
SS = ROOT / "A00_Common/spreadsheet"
@@ -38,7 +39,7 @@ def test_xlsx_without_widths_is_empty_and_garbage_is_safe():
def test_xlsx_sheet_carries_widths():
data = _xlsx({"A": 30})
sheets = grid._xlsx("a.xlsx", data)["시트"]
sheets = grid._xlsx("a.xlsx", data, workbook.read("a.xlsx", data).sheets)["시트"]
assert sheets and sheets[0]["열"]["A"]["폭"] == 30.0
+136
View File
@@ -0,0 +1,136 @@
"""857-1 지킴 — 불러오기 책 한 번 · 종류 한 말 · 일위대가 시트 없는 엑셀 올림 ·
「고를 재료」 판 무효 지문 · 판 셈 동안 M01 한 벌(`M01_MasterData_Store_Cache.steady`).
임시 storage 개인 층 · 실무 엑셀 견본(없는 PC = 건너뜀).
"""
from __future__ import annotations
import json
import sys
from pathlib import Path
import pytest
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
import helper_857_import as h # noqa: E402
def _path(name: str) -> Path:
p = h.sources().get(f"엑셀:{name}")
if not p or not p.exists():
pytest.skip(f"견본 없음 — {name}")
return p
def _opens(monkeypatch) -> list[str]:
import openpyxl
import xlrd
seen: list[str] = []
for mod, attr in ((openpyxl, "load_workbook"), (xlrd, "open_workbook")):
real = getattr(mod, attr)
def wrap(*a, _real=real, _tag=attr, **k):
seen.append(_tag)
return _real(*a, **k)
monkeypatch.setattr(mod, attr, wrap)
return seen
def test_종류_한_말():
from M02_MasterTemplete import M02_Hopyo_Stmate as hs
from M02_MasterTemplete import M02_San_Book as sb
from M02_MasterTemplete import M02_San_Workbook as wb
for names, kind in (
(["일위대가표", "단가산출근거"], "STmate"),
(["단가산출근거"], "STmate"),
(["일위대가", "단가산출"], "EST"),
(["일위대가"], None),
):
assert wb.kind_of(names) == kind
assert sb.kind_of(dict.fromkeys(names)) == kind
assert hs.is_stmate(names) == (kind == "STmate")
@pytest.mark.parametrize("name", ["봉화", "북부청사방"])
def test_올림_한_번에_책_한_번(monkeypatch, name):
from M02_MasterTemplete import M02_Hopyo_Router as router
path = _path(name)
seen = _opens(monkeypatch)
with h.personal():
row = router._upload(path.name, path.read_bytes(), {"id": 42, "이름": "시험"})
assert row["호표수"] > 0 and not row.get("읽기불가")
assert len(seen) == 1, seen
def test_일위대가_시트_없는_엑셀도_올라감_호표_빈_목록_단산은_보임():
from M02_MasterTemplete import M02_Hopyo_Excel as hx
from M02_MasterTemplete import M02_Hopyo_Router as router
from M02_MasterTemplete import M02_Hopyo_Store as hstore
from M02_MasterTemplete import M02_MasterTemplete_Store as store
from M02_MasterTemplete import M02_Sangeun_FromHopyo as fh
path = _path("2026수목")
data = path.read_bytes()
with pytest.raises(hx.ExcelError): # B09 내역서 길(그대로) — 일위대가 시트 없음 = 거절
hx.read_book(path.name, data)
with h.personal():
row = router._upload(path.name, data, {"id": 42, "이름": "시험"})
hp = hstore.read(store.root(), row["키"])
assert row["호표수"] == 0 and hp["호표"] == []
assert len(hp["단산"]) == 142 # 단가산출 시트 블록(둘 꼴 산근 수와 같음)
assert fh.has(store.root(), row["키"]) # 가져온 식 열기 자료 보관
def test_재료판_무효_지문_M01_이_바뀌면_다시_셈(monkeypatch):
from M02_MasterTemplete import M02_Hopyo_Router as router
from M02_MasterTemplete import M02_MasterTemplete_Store as store
from M02_MasterTemplete import M02_San_MatPick as mp
from M02_MasterTemplete import M02_Sangeun_FromHopyo as fh
path = _path("영덕계류")
with h.personal():
key = router._upload(path.name, path.read_bytes(), {"id": 42, "이름": "시험"})["키"]
first = mp.census(store.root(), key)
saved = json.loads(fh._path(store.root(), key).read_bytes())
assert saved[mp.MARK] == mp._mark() and saved[mp.CENSUS] == first
runs: list[int] = []
from M02_MasterTemplete import M02_Doc_FromNative as fn
emit = fn.emit
monkeypatch.setattr(fn, "emit", lambda *a, **k: runs.append(1) or emit(*a, **k))
assert mp.census(store.root(), key) == first and not runs # 같은 M01 = 저장본
monkeypatch.setattr(mp, "_mark", lambda: "다른 M01")
assert mp.census(store.root(), key) == first and runs # 지문 다름 = 다시 셈 · 답 같음
def test_판_셈_동안_M01_파일_자국_한_번(monkeypatch):
from M01_MasterData import M01_MasterData_Store_Cache as cache
from M02_MasterTemplete import M02_Doc_FromNative as fn
from M02_MasterTemplete import M02_Hopyo_Router as router
from M02_MasterTemplete import M02_MasterTemplete_Store as store
from M02_MasterTemplete import M02_San_MatPick as mp
from M02_MasterTemplete import M02_Sangeun_FromHopyo as fh
path = _path("영덕계류")
counts: list[int] = []
real = cache._stamps
monkeypatch.setattr(cache, "_stamps", lambda folder: counts.append(1) or real(folder))
with h.personal():
key = router._upload(path.name, path.read_bytes(), {"id": 42, "이름": "시험"})["키"]
counts.clear()
held = mp.census(store.root(), key)
with_hold = len(counts)
at = fh._path(store.root(), key)
src = fh._excel_of(at, json.loads(at.read_bytes()))
counts.clear()
for no in sorted(fn.numbers(src)): # 안 쥔 셈(지금 길) — 블록마다 자국을 다시 잼
with mp.using(None):
fn.emit(src, no)
bare = len(counts)
assert held and with_hold <= 3 < bare
+6 -3
View File
@@ -7,6 +7,7 @@
- 기본 = 빠른 표본(`QUICK_*`) · 전수 = 환경 `S857_ALL=1` · 견본 없는 PC = 그 갈래 건너뜀(수를 글로).
- 다르면 실패 + 갈래 이름 — 뜻대로 바꾼 걸음만 다시 뜸(바뀐 갈래를 커밋 글에):
`S857_ALL=1 ./venv/Scripts/python.exe resources/tester/test_857_import_golden.py --write`
(뒤에 「블록」 · 「올림」 = 그 갈래만)
"""
from __future__ import annotations
@@ -61,9 +62,11 @@ def test_엑셀_올림_호표_목록_칠_고정_재료_지문_같음():
if __name__ == "__main__":
if "--write" not in sys.argv or not ALL:
sys.exit(f"다시 뜨기 = {REDO}")
blocks, skip_b = h.blocks(True)
ups, table, skip_u = h.uploads(True)
body = {"판": 1, "블록": blocks, "올림": ups, "재료표": h.mat_counts(table)}
only = sys.argv[sys.argv.index("--write") + 1 :] # 갈래 하나만(블록 | 올림) · 없으면 둘 다
blocks, skip_b = (_want()["블록"], 0) if only == ["올림"] else h.blocks(True)
ups, table, skip_u = h.uploads(True) if only != ["블록"] else (_want()["올림"], None, 0)
mats = h.mat_counts(table) if table is not None else _want()["재료표"]
body = {"판": 1, "블록": blocks, "올림": ups, "재료표": mats}
FILE.write_text(
json.dumps(body, ensure_ascii=False, indent=1, sort_keys=True) + "\n", "utf-8", newline="\n"
)
+8 -1
View File
@@ -182,8 +182,15 @@ def test_올리기_목록_읽기_지우기(client):
def test_엉터리_시트없음_큰_파일_400(client, monkeypatch):
bad = _post(client, data=b"garbage", name="a.xls")
assert bad.status_code == 400 and "읽지 못함" in bad.json()["detail"]
none = _post(client, data=NO_SHEET.read_bytes(), name=NO_SHEET.name)
book = io.BytesIO()
import openpyxl
openpyxl.Workbook().save(book) # 일위대가 · 단가산출 시트 둘 다 없음
none = _post(client, data=book.getvalue(), name="빈책.xlsx")
assert none.status_code == 400 and none.json()["detail"] == "일위대가 시트 없음"
only = _post(client, data=NO_SHEET.read_bytes(), name=NO_SHEET.name) # 857-1 단가산출만 = 올라감
assert only.status_code == 200 and only.json()["호표수"] == 0
assert client.delete(URL.format("personal") + "/" + only.json()["키"]).status_code == 200
monkeypatch.setattr(hopyo_router, "HOPYO_MAX_BYTES", 1000)
big = _post(client)
assert big.status_code == 400 and "20 MB" in big.json()["detail"]
+2 -1
View File
@@ -16,6 +16,7 @@ from M02_MasterTemplete import M02_Hopyo_ReadEst as hb
from M02_MasterTemplete import M02_Hopyo_Excel as hx
from M02_MasterTemplete import M02_Hopyo_Stmate as st
from M02_MasterTemplete import M02_Hopyo_Store as hs
from M02_MasterTemplete import M02_San_Workbook as workbook
from M02_MasterTemplete import M02_Template_Layers as layers
from resources.tester import test_m02_hopyo_excel as base
from resources.tester.test_m02_hopyo_excel import ROOT, _post, master_hash
@@ -129,7 +130,7 @@ def test_기계_자원_하나로(books):
def test_노임_이름_어긋남_0(books):
names = hb.trade_names()
for tag in FILES:
sheets = hx._sheets(_path(tag).name, _path(tag).read_bytes())
sheets = workbook.read(_path(tag).name, _path(tag).read_bytes()).sheets
table = st._lists(sheets)
res = [r for b in books[tag]["단산"] for r in b["자원"] if r["갈래"] == "L" and r["이름"]]
assert res