Merge remote-tracking branch 'origin/dev' into sub_laptop_2
# Conflicts: # resources/tester/test_848_1_cover_layers.py
This commit is contained in:
@@ -73,7 +73,7 @@ export async function askRenew(
|
||||
{ label: ft("Renew_Item"), width: "28%" },
|
||||
{ label: ft("Renew_Upper") },
|
||||
{ label: ft("Renew_Kept") },
|
||||
{ label: "", width: "96px" },
|
||||
{ label: "", width: "120px" },
|
||||
],
|
||||
kept.map((n) => {
|
||||
const b = createButton({
|
||||
|
||||
@@ -77,7 +77,8 @@ export const diffOf = (src: Source | undefined): UiDiff | null =>
|
||||
|
||||
/** 칸 묶음 안 입력 · 고르기 · 이름 단추에 「바뀜」 상태 · 풍선(원래 값) */
|
||||
export function markDiff(box: HTMLElement, diff: UiDiff | null, was?: string): void {
|
||||
const nodes = box.matches(".ui-input, .ui-select, .ui-btn") ? [box] : [...box.querySelectorAll<HTMLElement>(".ui-input, .ui-select, .ui-btn.lstk-res")]; // prettier-ignore
|
||||
const own = ["ui-input", "ui-select", "ui-btn"].some((c) => box.classList.contains(c));
|
||||
const nodes = own ? [box] : ["ui-input", "ui-select", "lstk-res"].flatMap((c) => [...box.querySelectorAll<HTMLElement>(`.${c}`)]); // prettier-ignore
|
||||
for (const n of nodes) {
|
||||
setUiDiff(n, diff);
|
||||
if (diff && was !== undefined)
|
||||
|
||||
@@ -241,9 +241,11 @@ function rows(
|
||||
const v = vals[id];
|
||||
const t = lines.get(id);
|
||||
const head = katexNode(symTex(alias[id] ?? id));
|
||||
if (t !== undefined && hasVar(t)) {
|
||||
const tn = t === undefined ? null : nodeOf(t);
|
||||
// 848-3 수만인 식도 두 층 넘는 분수면(가져온 공식 줄 `Q = (4.5 + 5.5) ÷ 2 ÷ 0.35` 꼴) 아래 줄 나눔 규칙으로
|
||||
if (t !== undefined && (hasVar(t) || (tn && fracDepth(tn) > 1))) {
|
||||
flush();
|
||||
const n = nodeOf(t)!;
|
||||
const n = tn!;
|
||||
if (!machine && fracDepth(n) <= 1) {
|
||||
push({ h: formula(id, n, v, unit(id), vals, {}) });
|
||||
continue;
|
||||
|
||||
@@ -170,7 +170,7 @@ def copy_of(sk: dict, ctx: tuple | None) -> dict | None:
|
||||
calls = dc.closure(whole, [*dc.calls(root), *dc.upper_calls(got)], got.get("부름"))
|
||||
base = str((sk.get("바탕") or {}).get("로직") or "")
|
||||
seen = dc.doc_of(whole, base) if base else None # 바탕 M01 문서 판(「M01 새 판」 표지)
|
||||
origin = {"원본": {"키": base, "판": dc.fp(seen)}} if seen else {}
|
||||
origin = {"원본": {"키": base, "판": dc.doc_fp(seen)}} if seen else {}
|
||||
return {**got, **values, "문서": root, "부름": calls, **origin}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ def settle(out: dict, whole: Any, job: Any, raw: Any) -> dict:
|
||||
file = stored(out.get("키")) or {}
|
||||
have = file.get(KEY) if dc.has(file) else (raw.get(KEY) if dc.has(raw) else None)
|
||||
have = (
|
||||
upper(out, renew.form(out, have)) if have else have
|
||||
upper(out, renew.form(out, have, confirm=job == renew.CONFIRM)) if have else have
|
||||
) # 836-2 · ① 위 층 덮음(848-1) — 저장 때 굳음
|
||||
if have and have.get("따로") and job != skc.REGEN:
|
||||
if file and old_fp(file) != old_fp(out):
|
||||
@@ -248,6 +248,8 @@ def settle(out: dict, whole: Any, job: Any, raw: Any) -> dict:
|
||||
first = {**(dc.values_of(out[skc.KEY]) if skc.has(out) else {}), "부름": calls}
|
||||
if job != skc.REGEN and (have or {}).get("끊음"): # 안 바뀐 항목 고침 = 그대로(836-2)
|
||||
first["끊음"] = have["끊음"]
|
||||
if job != skc.REGEN: # 맡긴 기계 고침 · 옵션 값 · 지킨 칸 바탕(848-2)
|
||||
first |= {k: have[k] for k in renew.KEEP if (have or {}).get(k)}
|
||||
if (have or {}).get(
|
||||
UPPER
|
||||
): # ① = 저장본(프로젝트 층) · 밖은 `copy_of` 가 지금 기초 것으로(848-1)
|
||||
|
||||
@@ -525,9 +525,23 @@ def _reset_sc(doc: dict) -> tuple[dict, int]:
|
||||
return {**doc, "담은로직": lines}, n
|
||||
|
||||
|
||||
_OPT_KINDS = ("입력", "선택")
|
||||
|
||||
|
||||
def _options(mine: dict) -> dict:
|
||||
"""수식 문서 옵션 값 {열쇠: 값}(입력 · 선택)."""
|
||||
return {
|
||||
v["열쇠"]: v["연결"]["값"]
|
||||
for v in mine.get("변수") or []
|
||||
if isinstance(v, dict) and v.get("열쇠") and (v.get("연결") or {}).get("갈래") in _OPT_KINDS
|
||||
and "값" in (v.get("연결") or {})
|
||||
} # fmt: skip
|
||||
|
||||
|
||||
def formula_edits(doc: dict) -> list[str]:
|
||||
"""수식 길 고침(889) — 줄 · 식 고친 문서 · 끊은 부름 · 기계 고침 목록(가져온 식 = 없음 · 엑셀 원본 대비 ·
|
||||
바탕 기초 없는 SK = 없음 · 같게 할 기초가 없어 줄을 지키고 기계 고침은 줄마다 되돌림)."""
|
||||
바탕 기초 없는 SK = 없음 · 같게 할 기초가 없어 줄을 지키고 기계 고침은 줄마다 되돌림) ·
|
||||
줄 · 식 판정 = 셈 칸 지문(`doc_fp` · 이름 · 글 칸 뺌) · 옵션 값은 남기니 판정에서 뺌."""
|
||||
from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
from M02_MasterTemplete import M02_Doc_Import as imp
|
||||
|
||||
@@ -536,20 +550,28 @@ def formula_edits(doc: dict) -> list[str]:
|
||||
return []
|
||||
mine, first = got.get("문서") or {}, got.get("처음")
|
||||
|
||||
def bare(d: dict) -> dict:
|
||||
return {k: v for k, v in d.items() if k != "기계덮음"}
|
||||
def calc_fp(d: dict) -> str:
|
||||
rows = [
|
||||
{**v, "연결": {k: x for k, x in v["연결"].items() if k != "값"}}
|
||||
if isinstance(v, dict) and (v.get("연결") or {}).get("갈래") in _OPT_KINDS
|
||||
else v
|
||||
for v in d.get("변수") or []
|
||||
]
|
||||
return dc.doc_fp({**d, "변수": rows})
|
||||
|
||||
covers = {**(got.get("기계덮음") or {}), **(mine.get("기계덮음") or {})}
|
||||
items = [f"기계 고침 — {k}" for k in sorted(covers)]
|
||||
items += [f"끊은 부름 — {k}" for k in sorted(got.get("끊음") or {})]
|
||||
if got.get("따로") and (not isinstance(first, dict) or dc.fp(bare(mine)) != dc.fp(bare(first))):
|
||||
if got.get("따로") and (not isinstance(first, dict) or calc_fp(mine) != calc_fp(first)):
|
||||
items.insert(0, "수식 문서 고침(줄 · 식)")
|
||||
return items
|
||||
|
||||
|
||||
def reset(kind: str, doc: dict) -> tuple[dict, int]:
|
||||
"""[초기화] — (걷은 문서, 걷힌 고침 수) · 먼저 펼침(옛 참조 줄도 M01 키로) ·
|
||||
SK 수식 길 고침(따로 문서 · 끊음 · 기계 고침 · 889) = 재생성 할일로 함께 걷음(그 기초와 같게)."""
|
||||
SK 수식 길 고침(따로 문서 · 끊음 · 기계 고침 · 889) = 재생성 할일로 함께 걷음(그 기초와 같게) ·
|
||||
수식 문서 옵션 값 = 입력값으로 옮겨 남김(옵션 · 기본정보 그대로)."""
|
||||
from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
from M02_MasterTemplete import M02_Sangeun_Copy as skc
|
||||
|
||||
doc = flat_doc(kind, doc)
|
||||
@@ -557,7 +579,10 @@ def reset(kind: str, doc: dict) -> tuple[dict, int]:
|
||||
adds, n = _reset_adds(doc.get("더한줄") or [])
|
||||
n += const.covers_n(doc) # 790-2 상수 · 표값 덮개도 걷음(까닭 같이)
|
||||
items = formula_edits(doc)
|
||||
out = {**const.restore(doc), "더한줄": adds, **({skc.JOB: skc.REGEN} if items else {})}
|
||||
out = {**const.restore(doc), "더한줄": adds}
|
||||
if items:
|
||||
opts = _options((doc.get(dc.KEY) or {}).get("문서") or {})
|
||||
out |= {skc.JOB: skc.REGEN, "입력값": {**(doc.get("입력값") or {}), **opts}}
|
||||
return out, n + len(items)
|
||||
return _reset_sc(doc)
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ def test_왼쪽_제어_구역_방식_변수_칸(gc88):
|
||||
assert "버킷용량 q=[1]㎥" in [t.strip() for t in hour]
|
||||
assert "체적환산계수 f=[0.7]" in [t.strip() for t in hour]
|
||||
e = next(t.strip() for t in hour if t.strip().startswith("E입력"))
|
||||
assert e.startswith("E입력=[0.8]고침") # 고친 칸 표지
|
||||
assert e.startswith("E입력=[0.8]원래 값") # 고친 칸 = [원래 값] 단추(848-3 「고침」 글 → 테두리)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
@@ -15,8 +15,6 @@ from __future__ import annotations
|
||||
import copy
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Doc_Sk_Path as path
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
@@ -31,7 +29,6 @@ CUT = (
|
||||
"GC000085" # 흙깎기(기계) 보통토사 — 굴착기 1.0㎥(0201-0100) 부름 · 옵션 규모 · 지역 · 보정작업
|
||||
)
|
||||
PRICE = 142069 # 굴착기 1.0㎥ M01 가격
|
||||
WAIT = pytest.mark.xfail(reason="M02_Doc_Sk 세 줄(848-2 a · b · c) 붙인 뒤", strict=True)
|
||||
|
||||
|
||||
def _eq_move(monkeypatch, key: str, fn) -> None:
|
||||
@@ -127,7 +124,7 @@ def test_label_only(world, monkeypatch):
|
||||
|
||||
|
||||
def test_crew_list_kept(world, monkeypatch):
|
||||
"""㉡ 목록 칸 — 기계 인력 줄 바뀜 + 인력 고침 = 지킴 알림(목록 글) · 가격 고침 칸은 알림 없음."""
|
||||
"""㉡ 목록 칸 — 인력 줄 바뀜 + 인력 고침 = 지킴 알림(목록 글) · 가격 칸 알림 없음."""
|
||||
me = world["personal"]
|
||||
mine = [{"키": "LB:1048", "인": 2}]
|
||||
key = _machine_sk(me, {"값": {"가격": 150000}, "조종원": mine})
|
||||
@@ -137,9 +134,8 @@ def test_crew_list_kept(world, monkeypatch):
|
||||
assert note["M01"] == ["인력 LB:1048 1인 → LB:1048 1.5인"]
|
||||
|
||||
|
||||
@WAIT
|
||||
def test_upper_only(world, monkeypatch):
|
||||
"""㉣ 기초 고침(①)만 바뀜(+ 이름 글) = 따로 문서 그대로 · 내 고침 칸을 ① 이 바꾸면 지킴 알림(층 기초) ·
|
||||
"""㉣ 기초 고침(①)만 바뀜(+ 이름) = 따로 문서 그대로 · ① 이 내 고침 칸을 바꿈 = 지킴(층 기초) ·
|
||||
② 없는 칸(주연료)은 알림 없음."""
|
||||
me = world["personal"]
|
||||
key = _cut_sk(me, cover={"값": {"가격": 150000}})
|
||||
@@ -156,6 +152,7 @@ def test_upper_only(world, monkeypatch):
|
||||
assert got["문서"]["기계덮음"] == {DIG_NO: {"값": {"가격": 150000}}}
|
||||
[note] = got["사본"]["갱신"]
|
||||
assert (note["경로"], note["층"], note["전"], note["후"]) == ("값.가격", "기초", PRICE, 200000)
|
||||
assert got["셈"]["계"] > was["셈"]["계"] # 안 고친 칸(주연료 ①) = 따라옴 · 가격 = 내 값
|
||||
assert not got["사본"]["문서새판"]
|
||||
|
||||
|
||||
@@ -189,7 +186,7 @@ def _grow(d: dict) -> None:
|
||||
|
||||
|
||||
def test_structure_recopy(world, monkeypatch):
|
||||
"""㉤ 기초에 줄이 더해짐 = 다시 복사(따로 아님) · 기계 고침 · 옵션 값 다시 얹음 · 알림 다시복사."""
|
||||
"""㉤ 기초에 줄 더함 = 다시 복사(따로 아님) · 기계 고침 · 옵션 값 다시 얹음 · 알림 다시복사."""
|
||||
me = world["personal"]
|
||||
cover = {"값": {"가격": 150000}}
|
||||
key = _cut_sk(me, cover=cover)
|
||||
@@ -203,7 +200,6 @@ def test_structure_recopy(world, monkeypatch):
|
||||
assert note["다시얹음"] == ["규모 소규모"]
|
||||
|
||||
|
||||
@WAIT
|
||||
def test_structure_recopy_saved(world, monkeypatch):
|
||||
"""㉤ 다시 복사한 뒤 알림 [확인](저장) = 기계 고침 · 옵션 값 남음 · 알림 없음."""
|
||||
me = world["personal"]
|
||||
@@ -229,7 +225,6 @@ def test_save_keeps_base(world, monkeypatch):
|
||||
assert (note["전"], note["후"]) == (PRICE, PRICE * 2)
|
||||
|
||||
|
||||
@WAIT
|
||||
def test_confirm_clears(world, monkeypatch):
|
||||
"""㉥ 알림 [확인] 뒤 = 안 뜸 · 내 값 그대로 · 금액 같음."""
|
||||
me = world["personal"]
|
||||
@@ -288,3 +283,19 @@ def test_imported_same_rule(world, monkeypatch):
|
||||
with store.at(me):
|
||||
[note] = renew.notes(sk)
|
||||
assert (note["처리"], note["경로"], note["후"]) == ("지킴", "값.가격", PRICE * 2)
|
||||
|
||||
|
||||
def test_upper_cover_keeps_edited_doc(world, monkeypatch):
|
||||
"""㉣ 기초 문서의 `기계덮음`(①)만 바뀜 = 그 기초로 만든 따로 SK 문서 고침 그대로 · 알림 없음
|
||||
(문서 지문에서 덮음 뺌 — 848-1 이 남긴 경우)."""
|
||||
from resources.tester.test_836_2_sk_auto_renew import TOOL, _base, _edit
|
||||
|
||||
me = world["personal"]
|
||||
key = _base(me)
|
||||
_edit(me, key, "노무비 × 5%")
|
||||
was = _read(me, key)
|
||||
_doc_move(monkeypatch, "GC001109", lambda d: d.update(기계덮음={DIG_NO: {"값": {"가격": 1}}}))
|
||||
got = _read(me, key)
|
||||
assert got["사본"]["따로"] is True and got["사본"]["갱신"] == []
|
||||
assert got["문서"]["금액"][TOOL]["단가"] == "노무비 × 5%"
|
||||
assert got["셈"]["계"] == was["셈"]["계"] and not got["사본"]["문서새판"]
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
"""848-3(조사 889b F) — 가져온 공식 줄의 수만인 겹분수도 산출근거에서 두 층 안(줄 나눔 규칙) · 금액 · 문서 그대로.
|
||||
|
||||
짝 = `A00_Common/line_stack_out.ts` 공식 묶음(`block` — 수만인 식이 두 층 넘는 분수면 중간 줄 길) ·
|
||||
그리기 = 진짜 화면 코드를 가짜 DOM 으로(`helper_845_2_unit_show.cjs` 「전수」 · 기계 줄 = 위 · 아래 모두 봄).
|
||||
견본 = EST main 33(석축헐기 Q = (4.5 + 5.5) ÷ 2 ÷ 0.35) · 엑셀 북부청임도 43 — 엑셀 · 우리 두 판.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
from M02_MasterTemplete import M02_Doc_FromNative as fn
|
||||
from M02_MasterTemplete import M02_Doc_Import as dim
|
||||
from M02_MasterTemplete import M02_San_Xlsx as sx
|
||||
from M02_MasterTemplete import M02_Sangeun_Imported as imp
|
||||
from resources.tester import test_797_1a_import_flags as practice
|
||||
from resources.tester import test_810_1_estx as e
|
||||
from resources.tester import test_810_2_native_doc as t
|
||||
from resources.tester import test_846_2_work_view as w2
|
||||
|
||||
|
||||
def _saved(kind: str, tag: str):
|
||||
if kind == "엑셀":
|
||||
p = practice.FILES[tag]
|
||||
return fn.pack(sx.read(p.name, p.read_bytes()), p.name)
|
||||
p = e.FILES[tag]
|
||||
return fn.read(p.name, p.read_bytes())
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind,tag,no", [("EST", "main", 33), ("엑셀", "북부청임도", 43)])
|
||||
def test_가져온_식_겹분수_두_층_안(kind, tag, no):
|
||||
p = (practice.FILES if kind == "엑셀" else e.FILES)[tag]
|
||||
if not p or not p.exists():
|
||||
pytest.skip("견본 파일 없음")
|
||||
sk = t.sk_of(fn.emit(_saved(kind, tag), no))
|
||||
doc = dim.derive(sk, None, t.whole())
|
||||
cases = []
|
||||
for basis in ("엑셀", "우리"):
|
||||
sk2 = {**sk, imp.KEY: {**sk[imp.KEY], "단가기준": basis}}
|
||||
cases.append(
|
||||
{"키": basis, "문서": dim.view(doc, basis), "연결": dim.record(doc, sk2), "기계": True}
|
||||
)
|
||||
got = w2._js({"할일": "전수", "문서들": dc.ml._norm(cases), "보기": []})
|
||||
assert [b for g in got for b in g["bad"] if b[0] == "겹분수"] == []
|
||||
assert all(g["같음"] for g in got)
|
||||
@@ -4,6 +4,7 @@
|
||||
① 기초(GF000099 · 굴착기 0201-0070)를 바탕으로 한 SK 에 기계 고침을 수식 길로 저장 → 금액 바뀜.
|
||||
② 미리 보기 = 목록에 「기계 고침 — 0201-0070」 · 파일 그대로.
|
||||
③ 초기화 = 따로 · 기계 고침 걷힘 · 금액 = 처음(기초와 같음) · 다시 미리 보기 = 걷을 것 0.
|
||||
④ 수식 길로 옵션(지역) · 이름을 같이 고친 SK = 목록엔 기계 고침만 · 초기화 뒤 옵션 값 남음.
|
||||
"""
|
||||
|
||||
import copy as cp
|
||||
@@ -41,3 +42,18 @@ def test_문서_통째_초기화_기계_고침까지(tmp_path, monkeypatch):
|
||||
assert not file["수식"].get("따로") and mcv.COVER not in (file["수식"].get("문서") or {})
|
||||
assert path.read(key)["셈"]["계"] == was
|
||||
assert flat.reset_doc("sangeun", key, None, True, None)["걷힘"] == 0
|
||||
|
||||
with store.at(me):
|
||||
key = refs.create("sangeun", body)["이름"]
|
||||
first = path.read(key)
|
||||
doc = cp.deepcopy(first["문서"])
|
||||
area = next(v for v in doc["변수"] if v.get("열쇠") == "지역")
|
||||
area["연결"]["값"] = area["연결"]["목록"][1]
|
||||
doc["이름"] = "sub3임시 이름 고침"
|
||||
doc[mcv.COVER] = {NO: {"값": {"가격": 900000}}}
|
||||
path.save(key, {"문서": doc, "판": first["판"]})
|
||||
assert flat.reset_doc("sangeun", key, None, True, None)["목록"] == [f"기계 고침 — {NO}"]
|
||||
flat.reset_doc("sangeun", key, None, False, None)
|
||||
after = path.read(key)["문서"]
|
||||
kept = next(v for v in after["변수"] if v.get("열쇠") == "지역")["연결"]["값"]
|
||||
assert kept == area["연결"]["목록"][1] and mcv.COVER not in after
|
||||
|
||||
Reference in New Issue
Block a user