Merge remote-tracking branch 'origin/sub_laptop_1' into sub_laptop_7
This commit is contained in:
@@ -52,7 +52,7 @@ def test_길_셋():
|
||||
routes = {(r.path, tuple(sorted(r.methods))) for r in router_mod.router.routes}
|
||||
assert ("/api/projects/{project_id}/estimation", ("GET",)) in routes
|
||||
assert ("/api/projects/{project_id}/estimation", ("PUT",)) in routes
|
||||
assert ("/api/projects/{project_id}/estimation/prices", ("POST",)) in routes
|
||||
assert ("/api/projects/{project_id}/estimation/prices", ("POST",)) not in routes # 859-2
|
||||
main = (ROOT / "main.py").read_text(encoding="utf-8")
|
||||
assert "app.include_router(b09_estimation_router" in main
|
||||
|
||||
@@ -79,7 +79,7 @@ def test_사용자_값_다듬기_저장_자리(tmp_path):
|
||||
|
||||
def test_841_1_단가_책_자재만():
|
||||
"""841-1 — 노무 · 기계 · 운전사 · 연료 · 환율은 책 밖(B09 금액 = 사본 M02 엔진 값) · 자재만 굳힘."""
|
||||
book = prices.refresh_book(["EQ000004", "LB000048", "MT000401", "MO000002"])
|
||||
book = prices.make_book(["EQ000004", "LB000048", "MT000401", "MO000002"])
|
||||
rows = book["rows"]
|
||||
assert set(rows) == {"MT000401", "MO000002"} and "driver_factor" not in book
|
||||
assert rows["MO000002"]["prices"]["유가"] > 0
|
||||
@@ -109,7 +109,6 @@ def test_연결_없으면_빈_표와_연결_없음(tmp_path, monkeypatch):
|
||||
("compare", "b08:cement"),
|
||||
]
|
||||
assert any("연결된 구조물 조합 사본 없음" in n for n in body["notes"])
|
||||
assert body["book"] is None # GET 은 아무것도 쓰지 않음
|
||||
assert not (tmp_path / "B09_Estimation").exists()
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
"""203-1 B09 좌측 「데이터 점검」 묶음(사용자 60번).
|
||||
|
||||
- 묶음 이름 = 데이터 점검 · 안 설명 글 없음(굳힌 시각 · 까닭 = [업데이트] 공용 호버)
|
||||
- [단가 갱신] → [업데이트] · 낡으면(서버 `book_stale` = 지금 M01 로 굳힌 책과 다름) 점 배지(is-pending)
|
||||
- 묶음 이름 = 내역 점검 · [단가 갱신] · 낡음 점 배지 없음(859-2)
|
||||
- 「연결 점검」 탭 내용 = 묶음 안 목록(누르면 그 탭 그 줄) · 위 탭 줄에서 뺌
|
||||
- 701-2 첫 화면 = 설계내역서 · 목록 머리 「빈 줄 n」 = 설계내역서 금액 모르는 줄(줄마다 하나 · 까닭 모음) ·
|
||||
그 밖(호표 · 재료) = 「그 밖 확인 n곳」(탭 · 키마다 하나)
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@@ -15,24 +13,12 @@ ROOT = Path(__file__).resolve().parents[2]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from B09_Estimation import B09_Estimation_Prices as prices # noqa: E402
|
||||
from resources.tester.helper_b09_group_cards import TABS, run # noqa: E402
|
||||
|
||||
CHECK = "B09_Estimation/B09_Estimation_UI_Check.ts"
|
||||
SHELL = (ROOT / "B09_Estimation/B09_Estimation_UI_Shell.ts").read_text("utf-8")
|
||||
|
||||
|
||||
def test_묶음_이름_단추_글_설명_없음():
|
||||
assert (
|
||||
'createPanelCard("내역 점검", true)' in SHELL and "원가 단가" not in SHELL
|
||||
) # 269 공용 카드
|
||||
assert 'label: "단가 갱신",' in SHELL and 'label: "업데이트"' not in SHELL # 795-4 이름
|
||||
# 옛 굳힌 시각 안내 글(made) 없음 · 묶음 = 제목 · [단가 갱신] · 연결 점검
|
||||
assert "made.textContent" not in SHELL and "b09-estimation__hint" not in SHELL
|
||||
assert "section.append(refresh, check.list);" in SHELL # 제목 = 공용 카드(269)
|
||||
assert "check.draw(payload, sheets);" in SHELL
|
||||
|
||||
|
||||
def test_연결_점검_탭_없음_첫_화면_설계내역서():
|
||||
out = run(
|
||||
[TABS],
|
||||
@@ -50,8 +36,7 @@ def test_좌측_목록_이동_호버_배지():
|
||||
[TABS, CHECK],
|
||||
"""
|
||||
const moves = [];
|
||||
const refresh = document.createElement("button");
|
||||
const panel = createCheckPanel(refresh, (link) => moves.push(link));
|
||||
const panel = createCheckPanel((link) => moves.push(link));
|
||||
const sheets = {
|
||||
bill: { rows: [
|
||||
{ kind: "title", cost: "direct", key: "sec:1", name: "토공사", sum: null },
|
||||
@@ -68,11 +53,10 @@ const sheets = {
|
||||
{ tab: "material", key: "MT9", name: "모래", why: "단가 없음" },
|
||||
],
|
||||
};
|
||||
const payload = { book: { made: "2026-10-01T09:00:00" }, stale: "M01 에서 바뀐 단가 2",
|
||||
const payload = {
|
||||
notes: ["B08 자재 집계표 못 읽음"], inputs: { missing: ["EQ1", "LB2"] } };
|
||||
panel.draw(payload, sheets);
|
||||
const view = () => ({
|
||||
pending: refresh.classList.contains("is-pending"),
|
||||
texts: panel.list.children.map((c) => c.text),
|
||||
rows: [1, 3].flatMap((n) =>
|
||||
(panel.list.children[n]?.children ?? []).map((r) => [r.dataset.i, r.className, r.text])),
|
||||
@@ -81,19 +65,15 @@ const a = view();
|
||||
const blankBox = panel.list.children[1];
|
||||
const rowsBox = panel.list.children[3];
|
||||
rowsBox.children[1].click();
|
||||
const tipRefresh = hoverCalls.find((h) => h.root === refresh).text();
|
||||
const rowHover = hoverCalls.find((h) => h.root === panel.list);
|
||||
const tipRow = rowHover.text(rowsBox.children[0]);
|
||||
const tipBlank = [0, 1].map((n) => rowHover.text(blankBox.children[n]));
|
||||
panel.draw({ book: null, stale: null }, { gaps: [] });
|
||||
panel.draw({}, { gaps: [] });
|
||||
const b = view();
|
||||
const tipEmpty = refreshTip({ book: null, stale: "단가 아직 안 굳힘" });
|
||||
console.log(JSON.stringify({ a, b, moves, tipRefresh, tipRow, tipBlank, selector: rowHover.selector,
|
||||
tipEmpty }));
|
||||
console.log(JSON.stringify({ a, b, moves, tipRow, tipBlank, selector: rowHover.selector }));
|
||||
""",
|
||||
)
|
||||
a, b = out["a"], out["b"]
|
||||
assert a["pending"] and not b["pending"]
|
||||
# 빈 줄 = 직접공사 항목 중 금액 모름(관급 · 제목 · 아는 줄 빼고) · 같은 줄 까닭은 하나로
|
||||
assert a["texts"][0] == "금액 빈 줄 2" and a["texts"][2] == "그 밖 확인 2곳"
|
||||
assert a["rows"] == [
|
||||
@@ -107,28 +87,4 @@ console.log(JSON.stringify({ a, b, moves, tipRefresh, tipRow, tipBlank, selector
|
||||
assert a["texts"][4:] == ["B08 자재 집계표 못 읽음", "M01 에 없는 키 2 — EQ1 · LB2"]
|
||||
assert out["moves"] == [{"tab": "material", "key": "MT9"}]
|
||||
assert out["tipRow"] == "대가 원천 없음" and out["selector"] == "[data-i]"
|
||||
assert "단가 굳힘 2026-10-01 09:00:00" in out["tipRefresh"]
|
||||
assert "단가 갱신 가능 — M01 에서 바뀐 단가 2" in out["tipRefresh"]
|
||||
assert b["texts"] == ["금액 빈 줄 0"] and b["rows"] == []
|
||||
assert out["tipEmpty"].startswith("단가 아직 안 굳힘") and "단가 갱신 가능" in out["tipEmpty"]
|
||||
|
||||
|
||||
def test_배지_조건_서버_book_stale():
|
||||
keys = ["MT000401", "MT000338", "LB000002"] # 841-1 책 = 자재만(노임 키는 안 셈)
|
||||
book = json.loads(json.dumps(prices.refresh_book(keys), ensure_ascii=False))
|
||||
assert prices.book_stale(book, keys) is None # 방금 굳힌 책 = 업데이트 필요 없음
|
||||
assert prices.book_stale(None, keys) == "단가 아직 안 굳힘"
|
||||
first, *rest = list(book["rows"])
|
||||
old = {**book, "rows": {k: book["rows"][k] for k in rest}}
|
||||
old["rows"][rest[0]] = {**old["rows"][rest[0]], "prices": {}}
|
||||
assert prices.book_stale(old, keys) == "새 단가 줄 1 · M01 에서 바뀐 단가 1"
|
||||
router = (ROOT / "B09_Estimation/B09_Estimation_Router.py").read_text("utf-8")
|
||||
assert '"stale": await asyncio.to_thread(prices.book_stale, book, keys),' in router
|
||||
|
||||
|
||||
def test_배지_꼴_경고_색_토큰():
|
||||
css = (ROOT / "B09_Estimation/B09_Estimation_UI_Page.css").read_text("utf-8")
|
||||
block = css[css.index(".b09-options .ui-btn.is-pending::after") :]
|
||||
block = block[: block.index("}")]
|
||||
assert "position: absolute" in block and "border-radius: 50%" in block
|
||||
assert "background: var(--color-warning)" in block
|
||||
|
||||
@@ -22,7 +22,7 @@ def test_미리보기_계산_절차(tmp_path):
|
||||
got = logic_preview(tmp_path, PreviewBody(code="GF000134", given=given))
|
||||
assert got["unit"] == "㎥" and got["price"] and got["price"] > 0
|
||||
assert "Cm : 109.78 분" in got["lines"]
|
||||
assert any("60 * 15 * 1 * 0.9 / 109.78" in line for line in got["lines"])
|
||||
assert "작업량 = 7.378 ㎥/hr" in got["lines"] # 60 × 15 × 1 × 0.9 ÷ 109.78(B9-4 화면 꼴)
|
||||
assert got["lines"][-1].startswith("계 :")
|
||||
# 거리 늘면 단가도 늘음
|
||||
far = logic_preview(tmp_path, PreviewBody(code="GF000134", given={**given, "Cm": 200}))
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
"""296 B09 [업데이트] — 지워진 복사 정보는 업데이트에서 뺌(요구 190-4).
|
||||
|
||||
- ① B09 에서 지운 복사 항목 = 화면 캐시(user)를 같이 보냄 → 그 줄이 안 잇는 서고 사본 =
|
||||
수요에서 뺌 · 책에 안 살아남 · 캐시 그대로(지운 줄 안 되살림) · 저장은 안 함
|
||||
- ② M01 원본이 지워진 키 = 옛 책 줄 그대로(지우지도 바꾸지도 않음) · 낡음 까닭에서 빠짐
|
||||
- 나머지 = 지금처럼 M01 값으로 새로 굳힘 · user 안 보내면 옛 길 그대로
|
||||
임시 층(견본 마스터 · 임시 storage) · 실제 마스터 · 프로젝트는 안 씀.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from B09_Estimation import B09_Estimation_Bill_Library as library # noqa: E402
|
||||
from B09_Estimation import B09_Estimation_Prices as prices # noqa: E402
|
||||
from B09_Estimation import B09_Estimation_Router as router # noqa: E402
|
||||
from B09_Estimation import B09_Estimation_Store as store_b09 # noqa: E402
|
||||
from B09_Estimation.B09_Estimation_Linked import linked_resource_keys # noqa: E402
|
||||
from resources.tester.test_204_2_b09_bill_library import COMBO, world # noqa: E402, F401
|
||||
|
||||
|
||||
def _json(book):
|
||||
return json.loads(json.dumps(book, ensure_ascii=False))
|
||||
|
||||
|
||||
def _refresh(monkeypatch, root, body):
|
||||
seen = {}
|
||||
|
||||
async def fake_root(_):
|
||||
return root
|
||||
|
||||
async def fake_payload(_, at, draft=None):
|
||||
seen["draft"] = draft
|
||||
return {}
|
||||
|
||||
monkeypatch.setattr(router, "_project_root", fake_root)
|
||||
monkeypatch.setattr(router, "payload", fake_payload)
|
||||
asyncio.run(router.refresh_prices("00000000-0000-0000-0000-000000000001", body))
|
||||
return store_b09.read_book(root), seen["draft"]
|
||||
|
||||
|
||||
def test_지운_복사_항목_업데이트_뒤_안_살아남(world, monkeypatch): # noqa: F811
|
||||
root = world["root"]
|
||||
a = library.import_copy(root, "precombo", "system", None, world["key"])["폴더"]
|
||||
b = library.import_copy(root, "combo", "system", None, COMBO)["폴더"]
|
||||
keep_a = set(prices.refresh_book(linked_resource_keys(root, {a}))["rows"])
|
||||
every = set(prices.refresh_book(linked_resource_keys(root))["rows"])
|
||||
assert keep_a < every # b 사본만 부르는 줄이 있음
|
||||
# 화면 캐시 = b 줄을 지움(아직 [저장] 안 함 · 사본 폴더는 남음)
|
||||
ref = {"tab": "dg", "key": "DG:x", "lib": a}
|
||||
user = {"bill": {"v": 2, "rows": [{"key": "hand:1", "name": "줄", "qty": 1, "ref": ref}]}}
|
||||
book, draft = _refresh(monkeypatch, root, {"user": user})
|
||||
assert set(book["rows"]) == keep_a # 지운 사본 단가 줄 안 살아남
|
||||
assert draft["bill"]["rows"][0]["ref"]["lib"] == a # 응답 셈도 캐시로
|
||||
assert not (store_b09.folder(root) / store_b09.USER).exists() # 저장 안 함
|
||||
assert {f.name for f, _ in library.copies(root)} == {a, b} # 사본 정리는 [저장] 몫
|
||||
assert prices.book_stale(_json(book), linked_resource_keys(root, {a})) is None
|
||||
# user 안 보냄 = 옛 길(다 쓴 사본 전부)
|
||||
book, draft = _refresh(monkeypatch, root, None)
|
||||
assert set(book["rows"]) == every and draft is None
|
||||
|
||||
|
||||
def test_M01_원본_없는_항목_값_그대로_낡음_까닭_빠짐():
|
||||
gone = "MT999999" # 841-1 책 = 자재만 — 원본 없는 자재 키
|
||||
keys = ["MT000401", "MT000338", gone]
|
||||
old = _json(prices.refresh_book(["MT000401", "MT000338"]))
|
||||
kept = {"key": gone, "name": "지워진 자재", "origin": "M01", "prices": {"물가자료": 123.0}}
|
||||
old["rows"][gone] = kept
|
||||
old["rows"]["MT000401"] = {**old["rows"]["MT000401"], "prices": {}} # M01 에서 바뀐 단가
|
||||
assert prices.book_stale(old, keys) == "M01 에서 바뀐 단가 1" # 원본 없는 줄 = 까닭에 없음
|
||||
new = _json(prices.refresh_book(keys, old))
|
||||
assert new["rows"][gone] == kept # 지우지도 바꾸지도 않음
|
||||
assert new["rows"]["MT000401"]["prices"] != {} # 나머지 = 새로 굳힘
|
||||
assert set(new["rows"]) == set(old["rows"])
|
||||
assert prices.book_stale(new, keys) is None
|
||||
assert gone not in prices.refresh_book(keys)["rows"] # 옛 책 없으면 줄 없음(옛 길)
|
||||
|
||||
|
||||
def test_화면_업데이트_캐시_보냄_그대로_둠():
|
||||
shell = (ROOT / "B09_Estimation/B09_Estimation_UI_Shell.ts").read_text("utf-8")
|
||||
at = shell.index('"/estimation/prices",')
|
||||
assert "{ user, ...(refresh.dataset.b09Job" in shell[at : at + 200] # 795-4 할일 덧칸
|
||||
assert "\n true," in shell[at : at + 200]
|
||||
assert 'if (!keep) clearState("b09-estimation", projectId);' in shell
|
||||
assert "apply(next, !keep);" in shell
|
||||
@@ -1,75 +0,0 @@
|
||||
"""703-3 B09 [업데이트] 한 곳 — 단가 책 다시 굳힘 + 원본이 바뀐 구조물 사본 재적용.
|
||||
|
||||
- 미리 보기 수(`Refresh.preview`) = 적용 뒤 책 견줌(`Prices.book_diff`) 수 · 노임 판 전 → 후 · 고친 칸 수
|
||||
- 재적용 = 연결된 사본 중 원본이 바뀐 것만 · 하나가 막혀도 나머지 · 덮개(사용자 값) 안 건드림
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from B09_Estimation import B09_Estimation_Prices as prices # noqa: E402
|
||||
from B09_Estimation import B09_Estimation_Refresh as refresh # noqa: E402
|
||||
from B09_Estimation import B09_Estimation_Store as store # noqa: E402
|
||||
|
||||
#: 841-1 책 = 자재만(노임 키 = 노임 판만 셈) — 원목 · 미송각재 + 작업반장(건설업)
|
||||
KEYS = ["MT000401", "MT000338", "LB000001"]
|
||||
|
||||
|
||||
def test_책_견줌_미리보기_수_적용_수_같음(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(refresh, "changed_copies", lambda root: [])
|
||||
new = prices.refresh_book(KEYS)
|
||||
assert new["labor_edition"] == prices.labor_editions(KEYS) and new["labor_edition"]
|
||||
old = json.loads(json.dumps(new))
|
||||
old["rows"]["MT000401"] = {**old["rows"]["MT000401"], "prices": {}} # 옛 값
|
||||
del old["rows"]["MT000338"] # 새 줄
|
||||
old["labor_edition"] = {"건설업": "2025-09-01"}
|
||||
cover = {
|
||||
"S:a": {"x#0": {"qty": 1, "labor": 2}},
|
||||
"K:b": {"@copy": {"from": "S:a"}, "y#0": {"qty": 3}},
|
||||
}
|
||||
got = refresh.preview(tmp_path, old, KEYS, cover)
|
||||
after = prices.refresh_book(KEYS, old)
|
||||
diff = prices.book_diff(old, after)
|
||||
assert (got["새줄"], got["바뀐줄"]) == (diff["new"], diff["changed"]) == (1, 1)
|
||||
assert got["단가줄"] == 2 and got["고친칸"] == 3 and got["사본"] == []
|
||||
assert got["노임판"]["전"] == "건설업 2025-09"
|
||||
assert got["노임판"]["후"].startswith("건설업 2026")
|
||||
old.pop("labor_edition")
|
||||
assert refresh.preview(tmp_path, old, KEYS, None)["노임판"]["전"].startswith("굳힌 날 ")
|
||||
assert prices.book_diff(after, prices.refresh_book(KEYS, after)) == {"new": 0, "changed": 0}
|
||||
assert prices.book_stale(after, KEYS) is None
|
||||
|
||||
|
||||
def test_재적용_원본_바뀐_사본만_막혀도_나머지_덮개_그대로(tmp_path, monkeypatch):
|
||||
cover = {"S:a": {"x#0": {"qty": 0.3}}}
|
||||
store.write_user(tmp_path, {"daega_cover": cover})
|
||||
monkeypatch.setattr(
|
||||
refresh,
|
||||
"linked_snapshots",
|
||||
lambda root: {"p1": {"폴더": "a"}, "p2": {"폴더": "b"}, "p3": {"폴더": "c"}},
|
||||
)
|
||||
items = [
|
||||
{"폴더": "a", "이름": "가", "마스터바뀜": True},
|
||||
{"폴더": "b", "이름": "나", "마스터바뀜": False}, # 원본 그대로 = 안 함
|
||||
{"폴더": "c", "이름": "다", "마스터바뀜": True},
|
||||
{"폴더": "z", "이름": "끊김", "마스터바뀜": True}, # 연결 안 됨 = 안 함
|
||||
]
|
||||
monkeypatch.setattr(refresh.item_copy, "list_items", lambda root: items)
|
||||
calls = []
|
||||
|
||||
def fake(root, folder, who=None):
|
||||
calls.append(folder)
|
||||
if folder == "c":
|
||||
raise LookupError("원본 층 없음")
|
||||
|
||||
monkeypatch.setattr(refresh.item_copy, "reapply", fake)
|
||||
assert [c["이름"] for c in refresh.changed_copies(tmp_path)] == ["가", "다"]
|
||||
got = refresh.reapply_changed(tmp_path)
|
||||
assert calls == ["a", "c"]
|
||||
assert got == {"다시": ["가"], "막힘": ["다 — 원본 층 없음"]}
|
||||
assert store.read_user(tmp_path)["daega_cover"] == cover
|
||||
@@ -1,11 +1,10 @@
|
||||
"""719-2 · 855-F B9-5 공사 쪽 M02 단가산출(SK) — B09 대가 블록 · [재생성](업데이트) · 서고(임시
|
||||
"""719-2 · 855-F B9-5 공사 쪽 M02 단가산출(SK) — B09 대가 블록 · 구조물 [재적용] · 서고(임시
|
||||
storage · 실제 M01 읽기만).
|
||||
|
||||
- 사본 SK(수식 따로 사본) = 품셈 꼴 대가 블록(`Labor_Source.sangeun`) · 줄 = 문서 답 금액 줄
|
||||
(M02 에서 고친 문서 그대로) · 금액 = M02 SK 셈
|
||||
- [재생성] = SK 고친 뒤 다시 굳힘 — cover · cid · 입력값 · 고른자재 · B09 덮개 그대로 ·
|
||||
덮개 밑 값(base) = 새 단가산출 값 · 서고 사본(`sangeun`)도 원본판 다르면 다시 굳힘
|
||||
· 미리 보기 SK 줄
|
||||
- 구조물 [재적용](다시 지정) = SK 고친 뒤 다시 굳힘 — cover · cid · 입력값 · 고른자재 · B09 덮개
|
||||
그대로 · 덮개 밑 값(base) = 새 단가산출 값(859-2 프로젝트 안 [재생성] 걷음)
|
||||
(옛 칸 덮개 · 더한줄 SK · 내 자료집 = 옛 칸 SK 만들기는 855 2-C1 셈 은퇴 — 시험 없음)
|
||||
"""
|
||||
|
||||
@@ -16,7 +15,6 @@ import pytest
|
||||
|
||||
from B09_Estimation import B09_Estimation_Bill_Library as library
|
||||
from B09_Estimation import B09_Estimation_Prices as prices
|
||||
from B09_Estimation import B09_Estimation_Refresh as refresh
|
||||
from B09_Estimation import B09_Estimation_Sangeun as sangeun
|
||||
from B09_Estimation.B09_Estimation_Calc_Base import compute_base
|
||||
from B09_Estimation.B09_Estimation_Calc_Labor import compute_labor
|
||||
@@ -154,23 +152,6 @@ def test_구조물_사본_SK_줄_재생성_덮개_입력값_고른자재_그대
|
||||
assert daega2["owners"]["pipe@100.0"] in done
|
||||
|
||||
|
||||
def test_서고_SK_업데이트_미리보기_다시_굳힘(world, tmp_path):
|
||||
key = _mine(world)
|
||||
root, folder = _lib(world, tmp_path, key)
|
||||
assert library.changed(root) == []
|
||||
before = daega_inputs(root)
|
||||
cover_key = next(b for b in before["blocks"] if b["id"] == before["libs"][folder])["cover"]
|
||||
edit(world["personal"], key, 3)
|
||||
got = refresh.preview(root, None, [], None)
|
||||
assert [(x["키"], x["판"]) for x in got["단가산출"]] == [(key, "바뀜")]
|
||||
assert [c["폴더"] for c in got["사본"]] == [folder]
|
||||
assert refresh.reapply_changed(root)["다시"] == ["내 단가산출"]
|
||||
assert library.changed(root) == [] and [f.name for f, _ in library.copies(root)] == [folder]
|
||||
after = daega_inputs(root)
|
||||
block = next(b for b in after["blocks"] if b["id"] == after["libs"][folder])
|
||||
assert block["cover"] == cover_key and block["lines"][0]["qty"] == pytest.approx(0.108)
|
||||
|
||||
|
||||
def test_SK_하위_단가산출_줄_산근(world, tmp_path):
|
||||
"""사본 SK 문서 줄이 부른 하위 단가산출 = 대가 블록 산근 줄 · B09 산근 목록에 그 키(855-F B9-5)."""
|
||||
key = _sk(world["personal"], 바탕={"로직": "GF000206"}) # 합판거푸집 → GF000160 부름
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
# ruff: noqa: F811 — 임시 층 fixture(world)를 test_m02_labor_ref 에서 받아 씀
|
||||
"""795-4 프로젝트(B09) 사본 규칙 — 만든 때 그대로 · [단가 갱신] 값만 · [재생성] 따로 ·
|
||||
"""795-4 프로젝트(B09) 사본 규칙 — 만든 때 그대로 ·
|
||||
시점 섞임 고침(임시 storage · M01 은 메모리 덮개 · 정본 안 고침).
|
||||
|
||||
① 구조물 사본 단가 묶음 = M02 일위대가 사본 줄(만든 때) · 뒤에 M01 로직 · 노임이 바뀌어도
|
||||
사본 금액 그대로 · M01 에서 지워진 키 = 사본 줄 그대로 ② 사본 없는 옛 문서 = 옛 길(지금 M01)
|
||||
③ [저장] 새 단가 줄 = 사본 기준 시점 값 · 없는 자원만 지금 값 + 표지 · 옛 책 줄 그대로
|
||||
④ 연결 사본 `단가.json` 자원 줄 = 기준 시점 원천 ⑤ [단가 갱신] = 값만(사본 재적용 없음) ·
|
||||
[재생성] = 따로 누를 때만 ⑥ 미리 보기 꼴.
|
||||
④ 연결 사본 `단가.json` 자원 줄 = 기준 시점 원천(859-2 [단가 갱신] · [재생성] 걷음).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import copy
|
||||
import json
|
||||
from uuid import uuid4
|
||||
|
||||
from B09_Estimation import B09_Estimation_Linked as linked
|
||||
from B09_Estimation import B09_Estimation_Prices as prices
|
||||
from B09_Estimation import B09_Estimation_Refresh as refresh
|
||||
from B09_Estimation import B09_Estimation_Router as router
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Item_Prices as item_prices
|
||||
from M02_MasterTemplete import M02_Item_Source as source
|
||||
@@ -125,11 +120,9 @@ def test_book_new_rows_use_copy_basis():
|
||||
inputs = prices.build_inputs(None, [WOOD, BAR], None, frozen)
|
||||
assert [_price(r) for r in inputs["materials"]] == [111, _price(both["rows"][BAR])]
|
||||
assert inputs["now"] == [BAR] and prices.build_inputs(both, [WOOD, BAR])["now"] == [BAR]
|
||||
old = _json(prices.refresh_book([WOOD, BAR])) # 옛 책(사본 규칙 전) = 줄 · 값 그대로
|
||||
old = _json(prices.make_book([WOOD, BAR])) # 옛 책(사본 규칙 전) = 줄 · 값 그대로
|
||||
again = _json(prices.extend_book(old, [WOOD, BAR], frozen))
|
||||
assert again["rows"] == old["rows"] and again["now_keys"] == []
|
||||
fresh = _json(prices.refresh_book([WOOD, BAR], both)) # [단가 갱신] = 지금 값 · 표지 없음
|
||||
assert _price(fresh["rows"][WOOD]) != 111 and fresh["now_keys"] == []
|
||||
|
||||
|
||||
def test_frozen_rows_from_linked_copy(tmp_path):
|
||||
@@ -143,50 +136,3 @@ def test_frozen_rows_from_linked_copy(tmp_path):
|
||||
)
|
||||
inside = {r["키"]: r for d in bundle.values() if isinstance(d, dict) for r in d.get("줄") or []}
|
||||
assert all(inside[k] == row for k, row in got.items())
|
||||
|
||||
|
||||
def _router(monkeypatch, tmp_path, calls):
|
||||
async def root(_):
|
||||
return tmp_path
|
||||
|
||||
async def demand(*_):
|
||||
return [LB]
|
||||
|
||||
async def payload(*_a, **_k):
|
||||
return {"user": {}, "notes": [], "sheets": {}}
|
||||
|
||||
monkeypatch.setattr(router, "_project_root", root)
|
||||
monkeypatch.setattr(router, "_demand", demand)
|
||||
monkeypatch.setattr(router, "payload", payload)
|
||||
monkeypatch.setattr(router.store, "read_book", lambda _r: None)
|
||||
monkeypatch.setattr(router.store, "write_book", lambda _r, b: calls.append(("book", b)))
|
||||
monkeypatch.setattr(
|
||||
router.refresh,
|
||||
"reapply_changed",
|
||||
lambda *_a: calls.append("regen") or {"다시": ["A"], "막힘": []},
|
||||
)
|
||||
|
||||
|
||||
def test_price_refresh_default_regen_separate(monkeypatch, tmp_path):
|
||||
"""⑤ [단가 갱신] = 값만(사본 재적용 없음) · [재생성] = job 줄 때만."""
|
||||
calls = []
|
||||
_router(monkeypatch, tmp_path, calls)
|
||||
out = asyncio.run(router.refresh_prices(uuid4(), {"user": {}}, {}))
|
||||
assert "regen" not in calls and calls[-1][0] == "book"
|
||||
assert out["notes"][0].startswith("단가 갱신 — ")
|
||||
out = asyncio.run(router.refresh_prices(uuid4(), {"user": {}, "job": refresh.REGEN}, {}))
|
||||
assert calls.count("regen") == 1
|
||||
assert out["notes"][0].startswith("재생성 — 구조물 사본 1 다시 가져옴")
|
||||
|
||||
|
||||
def test_price_preview_shape():
|
||||
"""⑥ 미리 보기 — 바뀐 자원(사본 자원 줄 먼저 · 자재 단가 책) · 총괄 전 → 후."""
|
||||
old = _json(prices.refresh_book([WOOD, BAR]))
|
||||
old["rows"][WOOD] = {**old["rows"][WOOD], "prices": {"물가자료": 1}}
|
||||
new = _json(prices.refresh_book([WOOD, BAR], old))
|
||||
sheets = lambda g: {"total": {"subtotals": {"grand": g}}} # noqa: E731
|
||||
copies = [{"키": LB, "이름": "사본 노임", "전": 1, "후": 2}]
|
||||
got = refresh.price_preview(old, new, sheets(10), sheets(20), 3, copies)
|
||||
assert got["할일"] == "단가갱신" and (got["전"], got["후"], got["고친칸"]) == (10, 20, 3)
|
||||
assert [(r["키"], r["전"]) for r in got["바뀐자원"]] == [(LB, 1), (WOOD, {"물가자료": 1})]
|
||||
assert got["바뀐자원"][1]["후"] == new["rows"][WOOD]["prices"]
|
||||
|
||||
Reference in New Issue
Block a user