From 8956a6c9029a3e0698ec231ac9b5975743accc43 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Sat, 31 Oct 2026 16:14:36 +0900 Subject: [PATCH] =?UTF-8?q?test(707-1):=20=EB=82=B4=EC=97=AD=20=EC=A4=84?= =?UTF-8?q?=20=EC=9D=B4=EC=9D=8C=20=EC=8B=9C=ED=97=98=20=E2=80=94=20?= =?UTF-8?q?=EA=B0=99=EC=9D=80=20=EC=B1=85=20=EC=9D=BC=EC=9C=84=EB=8C=80?= =?UTF-8?q?=EA=B0=80=20=EC=9D=B4=EC=9D=8C=20=EB=8B=A8=EA=B0=80=20=C2=B7=20?= =?UTF-8?q?=EC=96=B4=EA=B8=8B=EB=82=A8=20=EC=95=8C=EB=A6=BC=20=C2=B7=20?= =?UTF-8?q?=EC=9D=B4=EC=9D=8C=20=EC=B0=BE=EA=B8=B0(=EA=B0=99=EC=9D=80=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=9D=B4=EB=A6=84=20=EB=B3=B8=EB=9C=AC?= =?UTF-8?q?=EB=A7=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- resources/tester/test_707_1_bill_import.py | 52 +++++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/resources/tester/test_707_1_bill_import.py b/resources/tester/test_707_1_bill_import.py index c558fb7c8..c69512d2c 100644 --- a/resources/tester/test_707_1_bill_import.py +++ b/resources/tester/test_707_1_bill_import.py @@ -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")} # 감싼 줄 · 다른 파일 · 안 쓰는 번 뺌