test(707-1): 내역 줄 이음 시험 — 같은 책 일위대가 이음 단가 · 어긋남 알림 · 이음 찾기(같은 파일 이름 본뜬만)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,10 +27,10 @@ from B09_Estimation.B09_Estimation_Calc_Bill import compute_estimation # noqa:
|
||||
|
||||
K = ROOT / "resources" / "knowledge" / "original" / "실무문서"
|
||||
FILES = {
|
||||
"기번3": K / "2024년 간선임도(기번3-울진.대흥)(공통)/1. 설계원본/01 내역자료/2024년 간선임도사업(기번3).xlsx",
|
||||
"기번3": K / "2024년 간선임도(기번3-울진.대흥)(공통)/1. 설계원본/01 내역자료/2024년 간선임도사업(기번3).xlsx", # noqa: E501
|
||||
"영월": K / "05. 동부청 영월/내역서/2024년 임도시설사업2차(산불진화_기번6)-영월.xlsx",
|
||||
"봉화": K / "04.산불 봉화/01. 내역서/2024년 산불진화임도 실시설계(기번41_현동)_ L=3.46km.xlsx",
|
||||
"거창": K / "01.산불거창(거창북상병곡)/01.내역서/00.25년_산불_거창(거창,북상,병곡,산8외)내역+수량.xlsx",
|
||||
"거창": K / "01.산불거창(거창북상병곡)/01.내역서/00.25년_산불_거창(거창,북상,병곡,산8외)내역+수량.xlsx", # noqa: E501
|
||||
} # fmt: skip
|
||||
#: (꼴, 항목 수, 엑셀 직접비 합)
|
||||
WANT = {
|
||||
@@ -194,3 +194,51 @@ def test_거울_TS_가_같은_값(parsed):
|
||||
) # fmt: skip
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert json.loads(result.stdout) == [compute_estimation(INPUTS, u, None, {}) for u in users]
|
||||
|
||||
|
||||
def test_이음_같은_책_일위대가_이음_단가_어긋남_알림(parsed):
|
||||
got = parsed["기번3"]
|
||||
link = {"tab": "dg", "key": "DG:5", "lib": "precombo@personal@1-3@SC-000001"}
|
||||
made, report, _ = _load(got, links={5: link})
|
||||
lines = [e for e in made["bill"]["rows"] if e.get("ref")]
|
||||
assert report["이음"] == 3 and len(lines) == 3 # 대가 5호표(종단규준틀) 공구마다
|
||||
assert lines[0]["ref"] == link and lines[0]["price"]["labor"] == 21936 # 고정 단가 곁에 남김
|
||||
same = {"daega": [{"no": 5, "key": "DG:5", "labor": 21936, "material": 3885, "expense": 0,
|
||||
"sum": 25821}]} # fmt: skip
|
||||
rows = compute_estimation(EMPTY, made, None, same)["bill"]["rows"]
|
||||
assert imp.differences(got, report, rows) == [] # 실무자료 사본 = 엑셀 단가 그대로
|
||||
other = {"daega": [{**same["daega"][0], "labor": 30000, "sum": 33885}]}
|
||||
rows = compute_estimation(EMPTY, made, None, other)["bill"]["rows"]
|
||||
diff = imp.differences(got, report, rows)
|
||||
assert len(diff) == 3 and {d["까닭"] for d in diff} == {"이음 단가 = 우리 셈"}
|
||||
# 사본이 없어짐(연결이 단가를 못 냄) = 고정 단가
|
||||
rows = compute_estimation(EMPTY, made, None, {})["bill"]["rows"]
|
||||
assert imp.differences(got, report, rows) == []
|
||||
|
||||
|
||||
def test_이음_찾기_같은_파일_이름_본뜬만(tmp_path, monkeypatch):
|
||||
from B09_Estimation import B09_Estimation_Router_Import as route
|
||||
|
||||
folder = tmp_path / "precombo"
|
||||
folder.mkdir()
|
||||
docs = {
|
||||
"SC-000001": {"층": "실무자료", "키": "HP-000001 제5호표", "파일": "a.xlsx"},
|
||||
"SC-000002": {"층": "실무자료", "키": "HP-000001 제5호표 2째 줄", "파일": "a.xlsx"},
|
||||
"SC-000003": {"층": "실무자료", "키": "HP-000002 제8호표", "파일": "b.xlsx"},
|
||||
"SC-000004": {"층": "실무자료", "키": "HP-000001 제9호표", "파일": "a.xlsx"},
|
||||
}
|
||||
for key, origin in docs.items():
|
||||
(folder / f"{key}.json").write_text(json.dumps({"본뜬": origin}), encoding="utf-8")
|
||||
|
||||
class Got:
|
||||
layer, owner = "personal", "1/3"
|
||||
|
||||
def grant(session, layer):
|
||||
if layer != "personal":
|
||||
raise route.HTTPException(status_code=409)
|
||||
return Got
|
||||
|
||||
monkeypatch.setattr(route.access, "grant", grant)
|
||||
monkeypatch.setattr(route.refs, "folder_of", lambda layer, owner: tmp_path)
|
||||
found = route._found({}, "a.xlsx", {5, 8})
|
||||
assert found == {5: ("personal", "1/3", "SC-000001")} # 감싼 줄 · 다른 파일 · 안 쓰는 번 뺌
|
||||
|
||||
Reference in New Issue
Block a user