From cb729416a31b1bf2ec3f8722e336100ad099f510 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Wed, 18 Nov 2026 01:42:27 +0900 Subject: [PATCH] =?UTF-8?q?refactor(855-E=20L2a):=20M01=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EB=AA=A9=EB=A1=9D=20=C2=B7=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=C2=B7=20=EB=B6=84=EB=A5=98=20=C2=B7=20=EC=83=81=EC=84=B8=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=ED=91=9C=20=C2=B7=20=EB=B3=84=EC=B9=AD?= =?UTF-8?q?=ED=8C=90=20=C2=B7=20=EC=A1=B0=ED=95=A9=20=EC=95=8C=EC=95=BD?= =?UTF-8?q?=EC=9D=84=20=EC=88=98=EC=8B=9D=20=EB=AC=B8=EC=84=9C=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=9D=BD=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 관문 `M01_MasterData_Doc.logic_files` — 수식 문서 파일을 옛 로직 파일 이름으로(머리 원문 · 부문 · 차례 · 줄 = 문서) · docs() 도 같은 읽기 - /logics · /groups/로직/files · /subs?group=로직 · /elements?group=로직 · /logic 이름표 · 목록 덧칸(인재경 = 문서 금액 줄 · 작업량 = 문서 결과) · /alias 로직 줄 · 조합 알약 · 담은 로직 요약 = 문서 - 남김(쓰기 짝 · L3) — /logic 셈 칸 · prices(옛 상세 몸) · 파일 판(해) · version(저장 409) - 쓰기 마무리 — 더한 로직 줄은 문서부터(Doc.ensure · 못 지으면 빈 문서 + 머리) · 새 문서 파일 머리 = 짝 로직 파일 머리 · sync_tags 가 이름 · 결과단위 · 출처 · 부품도 같게 - 서버 답 전후 243 건 다름 0 · 조합 알약 1,558 건 다름 0 - 시험 6 파일: 마스터만 임시 사본으로 바꾸던 준비에 수식 문서 사본도(목록이 문서에서 읽으므로 사본 저장이 보이게) · test_m01_cache 한 시험의 겹친 사본 걷음 Co-Authored-By: Claude Opus 5.5 --- M01_MasterData/M01_MasterData_Alias.py | 7 +- M01_MasterData/M01_MasterData_Doc.py | 121 ++++++++++++++++--- M01_MasterData/M01_MasterData_Store.py | 60 +++++---- M01_MasterData/M01_MasterData_Store_Combo.py | 5 +- M01_MasterData/M01_MasterData_Store_List.py | 30 +++-- M01_MasterData/M01_MasterData_Store_Make.py | 9 +- resources/tester/test_208_1_logic_alias.py | 2 + resources/tester/test_713_1_revise.py | 2 + resources/tester/test_794_1b_flow_gone.py | 2 + resources/tester/test_m01_api.py | 2 + resources/tester/test_m01_cache.py | 6 +- resources/tester/test_m01_copy.py | 2 + 12 files changed, 184 insertions(+), 64 deletions(-) diff --git a/M01_MasterData/M01_MasterData_Alias.py b/M01_MasterData/M01_MasterData_Alias.py index f474c0db4..69c2514e8 100644 --- a/M01_MasterData/M01_MasterData_Alias.py +++ b/M01_MasterData/M01_MasterData_Alias.py @@ -109,8 +109,11 @@ def board() -> dict[str, Any]: (str(v.get("키")), ma.norm(v.get(ALIAS))) for v in book.values() if v.get("상태") == "승인" } rows = [] - loaded, _ = store.loaded() - for file, data in loaded.items(): + logic = ( + store._docs().logic_files() + ) # 단가산출 기초 = 수식 문서 머리(855 L2 ⓐ) · 파일 차례는 그대로 + for file, data in store.loaded()[0].items(): + data = logic.get(file, {}) if data.get("그룹") == "로직" else data kind = kind_of(file, str(data.get("그룹") or "")) for row in data.get("줄") or []: if not str(row.get(ALIAS) or "").strip(): diff --git a/M01_MasterData/M01_MasterData_Doc.py b/M01_MasterData/M01_MasterData_Doc.py index b9310e1e8..1b7c086fd 100644 --- a/M01_MasterData/M01_MasterData_Doc.py +++ b/M01_MasterData/M01_MasterData_Doc.py @@ -63,14 +63,56 @@ def _stamp() -> tuple: return tuple((p.name, p.stat().st_mtime_ns) for p in sorted(folder().glob("수식_*.json"))) -def docs() -> dict[str, dict]: - """저장 문서 전부 {키: 문서} — 파일 시각이 같으면 다시 안 읽음.""" +def logic_files() -> dict[str, dict]: + """로직 그룹 관문(855 L2 ⓐ) — 수식 문서 파일을 옛 로직 파일 이름으로 + {로직 파일: {그룹 로직 · 원문 · 부문 · 차례 · 줄 = 문서}} · 파일 시각이 같으면 다시 안 읽음(읽기 전용).""" stamp = (str(folder()), _stamp()) if _memo.get("stamp") != stamp: - _memo.update(stamp=stamp, docs=ml.load_all(folder())) + files = {} + for path in sorted(folder().glob("수식_*.json")): + data = ml.load_file(path) + name = data.get("로직파일") or "로직_" + path.name.split("_", 1)[1] + head = {k: data[k] for k in md.FILE_TAGS if k in data} + files[name] = {"그룹": "로직", **head, "줄": data.get("줄") or []} + every = {str(d.get("키")): d for f in files.values() for d in f["줄"]} + _memo.update(stamp=stamp, files=files, docs=every) + return _memo["files"] + + +def docs() -> dict[str, dict]: + """저장 문서 전부 {키: 문서} — 파일 시각이 같으면 다시 안 읽음.""" + logic_files() return _memo["docs"] +#: 목록 · 상세가 문서에서 읽는 머리(이름표 `md.TAGS` 밖) — 로직 줄 고침도 같게(`sync_tags`) +HEAD = ("이름", "결과단위", "출처", "부품") + + +def head_of(doc: dict) -> dict: + """문서 머리(키 · 이름표 · 이름 · 결과단위 · 출처 · 부품) — 로직 목록 · 상세의 이름표 정본.""" + return {k: doc[k] for k in ("키", *md.TAGS, *HEAD) if k in doc} + + +def find(key: str) -> tuple[str, dict]: + """(옛 로직 파일 이름, 문서) — 없는 키 = 404.""" + for name, data in logic_files().items(): + for doc in data["줄"]: + if str(doc.get("키")) == key: + return name, doc + raise store.StoreError(404, f"없는 로직 「{key}」") + + +def head(ref: str) -> dict: + """`Master.logic` 과 같은 거름 · 같은 까닭 글 — 로직 키 → 문서 머리(조합 알약 · 담은 로직 요약).""" + if store.mk.GROUP_OF.get(store.mk.id_of(ref)) != "로직": + raise store.cm.mf.FormulaError(f"로직 아님 「{ref}」") + doc = docs().get(ref) + if doc is None: + raise store.cm.mf.FormulaError(f"없는 요소 「{ref}」") + return head_of(doc) + + def _dec(doc) -> dict: """화면 JSON(float) → Decimal 문서 — 저장 문서와 같은 수 꼴로 셈.""" return json.loads(json.dumps(doc, ensure_ascii=False), parse_float=Decimal, parse_int=Decimal) @@ -112,8 +154,10 @@ def _check(doc) -> dict: def read(key: str) -> dict: found = docs().get(key) fresh = found is None - if fresh: - row = store.logic(key)["logic"] # 없는 키 = 404 + if fresh: # 로직 줄은 있고 문서가 없는 키(옛 자료 받침 — 새 로직은 `ensure` 가 문서를 둠) + row = _row(key) + if row is None: + raise store.StoreError(404, f"없는 로직 「{key}」") found = md.blank(key, str(row.get("이름") or ""), str(row.get("결과단위") or "원")) out = _run(found) up = None if fresh else built(key) @@ -127,14 +171,24 @@ def preview(doc: dict, given: dict | None = None) -> dict: def _file_for(key: str) -> str: - """문서 파일 — 있던 파일 › 로직 파일 짝 › 자체.""" + """문서 파일 — 있던 파일 › 로직 줄이 든 로직 파일 짝(쓰기 짝 · L3 에서 걷음) › 자체.""" have = _where(key) if have: return have - try: - return ml.file_of(store.logic(key)["file"]) - except store.StoreError: - return OWN_FILE + for name, data in store.loaded()[0].items(): + if data.get("그룹") == "로직" and any( + str(r.get("키")) == key for r in data.get("줄") or [] + ): + return ml.file_of(name) + return OWN_FILE + + +def _new_file(name: str) -> dict: + """새 문서 파일 머리 — 짝 로직 파일의 이름 · 머리(원문 · 부문 · 차례)를 그대로(목록 분류 정본).""" + logic = "로직_" + name.split("_", 1)[1] + head = store.loaded()[0].get(logic) or {} + tags = {k: head[k] for k in md.FILE_TAGS if k in head} + return {"그룹": "수식문서", "로직파일": logic if head else "", **tags, "줄": []} def _row(key: str) -> dict | None: @@ -160,14 +214,49 @@ def sync_tags(keys) -> int: rows = data.get("줄") or [] for at, doc in enumerate(rows): row = want.get(str(doc.get("키"))) - if row is not None and md.tags_of(doc) != md.tags_of(row): - rows[at], hit = md.tag(doc, row), True + if row is not None and _headed(doc, row) != doc: + rows[at], hit = _headed(doc, row), True n += 1 if hit: put(path, data) return n +def _headed(doc: dict, row: dict) -> dict: + """문서 머리를 로직 줄 것과 같게 — 이름표(`md.tag`) + `HEAD`(있던 자리 그대로 · 줄에 없는 칸은 뺌).""" + out = md.tag(doc, row) + for k in HEAD: + if k in row: + out[k] = row[k] + else: + out.pop(k, None) + return out + + +def ensure(key: str) -> bool: + """새 로직 줄의 수식 문서 — 빌더와 같은 문서(`make`) · 못 지으면 빈 문서 + 머리(목록이 문서에서 읽으므로 + 문서 없는 로직 0 · 열면 빈 문서는 그대로) · 지어 넣었거나 이미 있음 = True.""" + if make(key): + return True + row = _row(key) + if row is None: + return False + blank = md.blank(key, str(row.get("이름") or ""), str(row.get("결과단위") or "원")) + blank = { + **dict(list(blank.items())[:5]), + "출처": row.get("출처"), + **dict(list(blank.items())[5:]), + } + with _LOCK: + if key in docs(): + return True + path = folder() / _file_for(key) + data = ml.load_file(path) if path.exists() else _new_file(path.name) + data.setdefault("줄", []).append(_headed(blank, row)) + put(path, data) + return False + + def built(key: str) -> dict | None: """빌더가 지을 그 키 문서(옛 로직 줄 변환 · `build_수식문서_802_2`) · 로직 줄 없음 · 변환 틀림 = None.""" for data in store.loaded()[0].values(): @@ -225,9 +314,7 @@ def make(key: str) -> bool: ): return False path = folder() / _file_for(key) - data = ( - ml.load_file(path) if path.exists() else {"그룹": "수식문서", "로직파일": "", "줄": []} - ) + data = ml.load_file(path) if path.exists() else _new_file(path.name) data.setdefault("줄", []).append(doc) put(path, data) return True @@ -263,9 +350,7 @@ def save(doc: dict, 판: str | None = None) -> dict: doc = layered(doc, key) name = _file_for(key) path = folder() / name - data = ( - ml.load_file(path) if path.exists() else {"그룹": "수식문서", "로직파일": "", "줄": []} - ) + data = ml.load_file(path) if path.exists() else _new_file(path.name) rows = data.setdefault("줄", []) at = next((i for i, d in enumerate(rows) if str(d.get("키")) == key), None) if 판 is not None and version_of(None if at is None else rows[at]) != 판: diff --git a/M01_MasterData/M01_MasterData_Store.py b/M01_MasterData/M01_MasterData_Store.py index ae828d019..0324711a8 100644 --- a/M01_MasterData/M01_MasterData_Store.py +++ b/M01_MasterData/M01_MasterData_Store.py @@ -110,23 +110,32 @@ def chapter_order(data: dict) -> int: return data.get("차례") or 9999 +def _docs(): + from M01_MasterData import M01_MasterData_Doc as doc_store # Doc 이 이 파일을 부름 — 늦게 + + return doc_store + + def files_of(group: str) -> list[dict]: + """로직 = 수식 문서 파일(855 L2 ⓐ) · 판(해) · version 은 로직 파일(저장 409 짝 · L3 에서 문서로).""" if group not in cm.mf.GROUPS: raise StoreError(404, f"없는 그룹 「{group}」") + logic = _docs().logic_files() if group == "로직" else None out = [] - for name in cm.mmf.names(FOLDER): + for name in sorted(logic) if logic is not None else cm.mmf.names(FOLDER): if name != f"{group}.json" and not name.startswith(f"{group}_"): continue data, version = read(name) + head = data if logic is None else logic[name] out.append( { "file": name, - "book": _book(data), - "chapter": chapter_of(name, data), + "book": _book(head), + "chapter": chapter_of(name, head), "edition": data.get("판"), - "rows": len(data.get(items_key(data)) or []), + "rows": len(head.get(items_key(head)) or []), "version": version, - "order": chapter_order(data), + "order": chapter_order(head), } ) return sorted(out, key=lambda f: (f["order"], f["file"])) @@ -173,7 +182,7 @@ def subs(file: str = "", group: str = "") -> dict: name = mk.CHAPTER.match(info["file"]) if not name: continue - data = read(info["file"])[0] + data = _docs().logic_files()[info["file"]] if group == "로직" else read(info["file"])[0] kind = " ".join(x for x in (data.get("원문"), data.get("부문")) if x) slot = found.setdefault(kind, {"name": kind, "book": data.get("원문"), "details": []}) slot["details"].append(mk.detail_of(info["file"])) @@ -335,6 +344,7 @@ def table(file: str, key: str) -> dict: def _logic_files(files: dict[str, dict]): + """로직 파일 줄(옛 엔진 시험 셈 `_swap` 몫 · L3 에서 걷음).""" for name, data in files.items(): if data.get("그룹") == "로직": yield name, data @@ -342,11 +352,10 @@ def _logic_files(files: dict[str, dict]): def logics(sub: str, detail: str, q: str, blocked: int | None, owner: str = "") -> list[dict]: """로직 목록 — 구분 · 상세구분 · 소유 · 찾기로 거름(장 차례대로 · 파일을 가로지름). - 막힘은 미리 세어 둔 값(`blocks`) — 목록에서 줄마다 검사를 돌리지 않음.""" - files, _ = loaded() + 줄 = 수식 문서 머리(855 L2 ⓐ) · 막힘은 미리 세어 둔 값(`blocks`) — 목록에서 줄마다 검사를 돌리지 않음.""" why_of = blocks() out = [] - for name, data in sorted(_logic_files(files), key=lambda f: chapter_order(f[1])): + for name, data in sorted(_docs().logic_files().items(), key=lambda f: chapter_order(f[1])): for row in data.get("줄") or []: if (sub and row.get("구분") != sub) or (detail and row.get("상세구분") != detail): continue @@ -382,22 +391,22 @@ def logics(sub: str, detail: str, q: str, blocked: int | None, owner: str = "") def logic(key: str) -> dict: - """로직 하나 — 키는 전체에서 하나.""" + """로직 하나 — 키는 전체에서 하나 · 있는지 · 파일 · 이름표 = 수식 문서(855 L2 ⓐ) · 셈 칸(입력 · 호표 …) + · `prices` · `version` = 로직 파일(옛 상세 몸 · 저장 짝 — 856 · L3 에서 걷음).""" files, whole = loaded() - for name, data in _logic_files(files): - for row in data.get("줄") or []: - if str(row.get("키")) == key: - reasons = cache.reasons(key, whole) # 수식 문서 기준(855 2-B3) - _, version = read(name) - return { - "file": name, - "version": version, - "logic": row, - "blocked": bool(reasons), - "reasons": reasons, - "prices": _prices(whole, row), - } - raise StoreError(404, f"없는 로직 「{key}」") + name, doc = _docs().find(key) + row = next((r for r in (files.get(name) or {}).get("줄") or [] if str(r.get("키")) == key), {}) + head, named = _docs().head_of(doc), (*_docs().md.TAGS, *_docs().HEAD) + row = {k: head.get(k, v) for k, v in row.items() if k in head or k not in named} | head + reasons = cache.reasons(key, whole) # 수식 문서 기준(855 2-B3) + return { + "file": name, + "version": read(name)[1], + "logic": row, + "blocked": bool(reasons), + "reasons": reasons, + "prices": _prices(whole, row), + } def _brief(ref: str, row: dict) -> dict: @@ -451,7 +460,8 @@ def elements(group: str, q: str, limit: int) -> dict: if group not in cm.mf.GROUPS: raise StoreError(404, f"없는 그룹 「{group}」") hits = [] - for name, data in loaded()[0].items(): + every = _docs().logic_files() if group == "로직" else loaded()[0] # 로직 = 수식 문서(855 L2 ⓐ) + for name, data in every.items(): if data.get("그룹") != group: continue for row in data.get(items_key(data)) or []: diff --git a/M01_MasterData/M01_MasterData_Store_Combo.py b/M01_MasterData/M01_MasterData_Store_Combo.py index 11ac9774f..7145c0b70 100644 --- a/M01_MasterData/M01_MasterData_Store_Combo.py +++ b/M01_MasterData/M01_MasterData_Store_Combo.py @@ -100,7 +100,7 @@ def _brief(whole, row: dict) -> list[dict]: key = str(one.get("로직") or "") if isinstance(one, dict) else "" head = {"차례": at, "로직": key, "메모": one.get("메모") if isinstance(one, dict) else None} try: - got = whole.logic(key) + got = store._docs().head(key) # 수식 문서 머리(855 L2 ⓐ) except cm.mf.FormulaError as e: out.append({**head, "ok": False, "까닭": str(e)}) continue @@ -173,12 +173,11 @@ def combo_inputs(key: str) -> dict: def combo_pills(row: dict) -> dict: """조합 줄 하나(어느 층이든 · M02 조합 층 저장소가 부름)의 알약 — 규칙은 `combo_inputs`.""" - whole = store.loaded()[1] pills: dict[tuple[str, str], dict] = {} for one in mcb.items(row): code = str(one.get("로직") or "") if isinstance(one, dict) else "" try: - got = whole.logic(code) + got = store._docs().head(code) # 수식 문서 머리(855 L2 ⓐ) except cm.mf.FormulaError: continue per = mu.per(got.get("결과단위")) # 결과단위 배 읽기 한 벌(712-2) diff --git a/M01_MasterData/M01_MasterData_Store_List.py b/M01_MasterData/M01_MasterData_Store_List.py index fdcc738e0..093a8470f 100644 --- a/M01_MasterData/M01_MasterData_Store_List.py +++ b/M01_MasterData/M01_MasterData_Store_List.py @@ -5,7 +5,9 @@ - `작업량` = 돈 아닌 로직(`결과` 칸) · `부모` = 그 작업량을 부르는 로직(목록에서 그 밑으로 접음). - `부르는수` · `불리는수` = 로직끼리 부르기(기계경비 포함 · `Store_Cache.counted`). - `관련` = 비고 글의 절 번호(「1-5-6(주③)」 · 「별도」 참조)가 가리키는 로직 — 계산 밖 링크. -- `인재경` = 호표 · 덧줄 줄 수 `{인력, 재료, 경비, 하위}`(712-1 `master_bundle.bundle` 한 벌). +- `인재경` = 수식 문서 금액 줄 수 `{인력, 재료, 경비, 하위}` — 비목(`master_bundle.BY_ITEM`) · + 「묶음」 줄은 단가가 부르는 문서가 기계경비(`is_machine`)면 경비 · 아니면 하위(옛 호표 · 덧줄 셈과 1,521 같음). +줄 = 수식 문서(855 L2 ⓐ · `M01_MasterData_Doc.logic_files`). """ from __future__ import annotations @@ -45,20 +47,26 @@ def _related(row: dict, book: tuple[str, str], by_section: dict) -> list[str]: return list(out) -def _bundles(whole, row: dict) -> dict[str, int]: - got = Counter(mbd.bundle(whole, x)[0] for x in [*row.get("호표", []), *row.get("덧줄", [])]) +def _bundles(doc: dict, docs: dict[str, dict]) -> dict[str, int]: + got: Counter = Counter() + links = {} + for v in doc.get("변수") or []: + for k in ("열쇠", "기호", "이름"): + links.setdefault(v.get(k), v.get("연결") or {}) + for line in doc.get("금액") or []: + if line.get("비목") in mbd.BY_ITEM: + got[mbd.BY_ITEM[line["비목"]]] += 1 + continue + called = docs.get(str((links.get(str(line.get("단가") or "")) or {}).get("키") or "")) + got["경비" if mbd.is_machine(called) else "하위"] += 1 return {name: got.get(name, 0) for name in mbd.BUNDLES} def extras() -> dict[str, dict]: """로직 키 → 덧칸 — 목록 전체로 셈(거른 목록이어도 묶음 수 · 부르는 수는 전체 기준).""" - files, whole = store.loaded() - rows = [ - (name, data, row) - for name, data in files.items() - if data.get("그룹") == "로직" - for row in data.get("줄") or [] - ] + docs = store._docs() + every = docs.docs() + rows = [(name, data, row) for name, data in docs.logic_files().items() for row in data["줄"]] calls = {key: got[1] for key, got in cache.counted(store.FOLDER).items()} called = Counter(k for got in calls.values() for k in got) parents: dict[str, list[str]] = defaultdict(list) @@ -86,7 +94,7 @@ def extras() -> dict[str, dict]: "부르는수": len(calls.get(key, ())), "불리는수": called.get(key, 0), "관련": _related(row, _book(data), by_section), - "인재경": _bundles(whole, row), + "인재경": _bundles(row, every), } return out diff --git a/M01_MasterData/M01_MasterData_Store_Make.py b/M01_MasterData/M01_MasterData_Store_Make.py index cc2df9cfa..5f1dec18d 100644 --- a/M01_MasterData/M01_MasterData_Store_Make.py +++ b/M01_MasterData/M01_MasterData_Store_Make.py @@ -267,9 +267,14 @@ def save(batch: list[dict], confirmed: bool = False) -> dict: def _sync_tags(batch: list[dict], added: list[dict]) -> None: - """고친 · 더한 로직 줄 이름표(비고 · 별칭 · 이름 · 개정 …)를 수식 문서에도(855 L1 · 두 곳 같게).""" + """고친 · 더한 로직 줄 이름표(비고 · 별칭 · 이름 · 개정 …)를 수식 문서에도(855 L1 · 두 곳 같게) · + 더한 로직 줄은 문서부터 둠(`Doc.ensure` — 목록이 문서에서 읽음 · 855 L2 ⓐ).""" from M01_MasterData import M01_MasterData_Doc as doc_store # Doc 이 이 파일을 늦게 부름 — 늦게 + files = store.loaded()[0] + for a in added: + if (files.get(a["file"]) or {}).get("그룹") == "로직": + doc_store.ensure(a["key"]) keys = {a["key"] for a in added} | { str(c.get("key")) for p in batch @@ -375,7 +380,7 @@ def logic_new(logic: dict, owner: str = OWNERS[0]) -> dict: before = set(_keys()) done = _write([{"op": "add", "row": _clean(logic, owner)}]) key = next((k for k in reversed(_keys()) if k not in before), "") - made = doc_store.make(key) if key else False + made = doc_store.ensure(key) if key else False return {**done, "key": key, "logic": store.logic(key)["logic"] if key else {}, "수식문서": made} diff --git a/resources/tester/test_208_1_logic_alias.py b/resources/tester/test_208_1_logic_alias.py index dbc235399..47f022a47 100644 --- a/resources/tester/test_208_1_logic_alias.py +++ b/resources/tester/test_208_1_logic_alias.py @@ -101,6 +101,8 @@ def client(tmp_path: Path, monkeypatch) -> TestClient: shutil.copy(path, tmp_path / path.name) shutil.copytree(REAL / "기계", tmp_path / "기계") # 기계 = 폴더(826-2) monkeypatch.setattr(store, "FOLDER", tmp_path) + shutil.copytree(REAL / "수식문서", tmp_path / "수식문서") # 로직 목록 = 수식 문서(855 L2 ⓐ) + monkeypatch.setattr(store._docs().ml, "FOLDER", tmp_path / "수식문서") app = FastAPI() app.include_router(router_module.router) return TestClient(app) diff --git a/resources/tester/test_713_1_revise.py b/resources/tester/test_713_1_revise.py index bac3deeed..837b0b9fd 100644 --- a/resources/tester/test_713_1_revise.py +++ b/resources/tester/test_713_1_revise.py @@ -28,6 +28,8 @@ def client(tmp_path_factory) -> TestClient: shutil.copytree(REAL / "기계", folder / "기계") # 기계 = 폴더(826-2) patch = pytest.MonkeyPatch() patch.setattr(store, "FOLDER", folder) + shutil.copytree(REAL / "수식문서", folder / "수식문서") # 로직 목록 = 수식 문서(855 L2 ⓐ) + patch.setattr(store._docs().ml, "FOLDER", folder / "수식문서") app = FastAPI() app.include_router(router_module.router) yield TestClient(app) diff --git a/resources/tester/test_794_1b_flow_gone.py b/resources/tester/test_794_1b_flow_gone.py index 8aa8515c8..7a038a109 100644 --- a/resources/tester/test_794_1b_flow_gone.py +++ b/resources/tester/test_794_1b_flow_gone.py @@ -31,6 +31,8 @@ def client(tmp_path: Path, monkeypatch) -> TestClient: shutil.copy(path, master / path.name) shutil.copytree(REAL / "기계", master / "기계") # 기계 = 폴더(826-2) monkeypatch.setattr(store, "FOLDER", master) + shutil.copytree(REAL / "수식문서", master / "수식문서") # 로직 목록 = 수식 문서(855 L2 ⓐ) + monkeypatch.setattr(store._docs().ml, "FOLDER", master / "수식문서") app = FastAPI() app.include_router(m01_router.router) app.include_router(df.router) diff --git a/resources/tester/test_m01_api.py b/resources/tester/test_m01_api.py index b8f38cfdc..b08113d5e 100644 --- a/resources/tester/test_m01_api.py +++ b/resources/tester/test_m01_api.py @@ -47,6 +47,8 @@ def client(tmp_path: Path, monkeypatch) -> TestClient: shutil.copy(path, tmp_path / path.name) shutil.copytree(REAL / "기계", tmp_path / "기계") # 기계 = 폴더(826-2) monkeypatch.setattr(store, "FOLDER", tmp_path) + shutil.copytree(REAL / "수식문서", tmp_path / "수식문서") # 로직 목록 = 수식 문서(855 L2 ⓐ) + monkeypatch.setattr(store._docs().ml, "FOLDER", tmp_path / "수식문서") app = FastAPI() app.include_router(router_module.router) return TestClient(app) diff --git a/resources/tester/test_m01_cache.py b/resources/tester/test_m01_cache.py index 22887f2a0..6c4501158 100644 --- a/resources/tester/test_m01_cache.py +++ b/resources/tester/test_m01_cache.py @@ -33,6 +33,8 @@ def client(tmp_path: Path, monkeypatch) -> TestClient: shutil.copy(path, tmp_path / path.name) shutil.copytree(REAL / "기계", tmp_path / "기계") # 기계 = 폴더(826-2) monkeypatch.setattr(store, "FOLDER", tmp_path) + shutil.copytree(REAL / "수식문서", tmp_path / "수식문서") # 로직 목록 = 수식 문서(855 L2 ⓐ) + monkeypatch.setattr(store._docs().ml, "FOLDER", tmp_path / "수식문서") app = FastAPI() app.include_router(router_module.router) return TestClient(app) @@ -114,9 +116,7 @@ def test_부르는_로직이_바뀌면_다른_파일의_줄도_다시_센다( 다른 파일의 부르는 줄도 다시 세어 막힘.""" from M01_MasterData import M01_MasterData_Doc as doc_store - docs = tmp_path / "수식문서" - shutil.copytree(REAL / "수식문서", docs) - monkeypatch.setattr(doc_store.ml, "FOLDER", docs) + docs = tmp_path / "수식문서" # 사본 = 준비(`client`)가 둠 doc_store._memo.clear() assert [x for x in _logics(client) if x["키"] == CALLER][0]["blocked"] is False diff --git a/resources/tester/test_m01_copy.py b/resources/tester/test_m01_copy.py index fdb47e085..4729f3a42 100644 --- a/resources/tester/test_m01_copy.py +++ b/resources/tester/test_m01_copy.py @@ -37,6 +37,8 @@ def client(tmp_path: Path, monkeypatch) -> TestClient: shutil.copy(path, tmp_path / path.name) shutil.copytree(REAL / "기계", tmp_path / "기계") # 기계 = 폴더(826-2) monkeypatch.setattr(store, "FOLDER", tmp_path) + shutil.copytree(REAL / "수식문서", tmp_path / "수식문서") # 로직 목록 = 수식 문서(855 L2 ⓐ) + monkeypatch.setattr(store._docs().ml, "FOLDER", tmp_path / "수식문서") app = FastAPI() app.include_router(router_module.router) return TestClient(app)