- [업데이트] = 화면 캐시(user)를 같이 보냄 · 캐시 그대로 둠(지운 줄 안 되살림 · 저장 안 함) - 서버 수요 = 캐시 줄이 잇는 서고 사본만(지운 줄의 사본 단가 줄 안 살아남) - M01 원본이 지워진 키 = 옛 책 줄 그대로 · 낡음 까닭에서 빠짐 - 시험 test_296_b09_update_skip_deleted Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Se7ytqbohmBQnfYpwYFnYf
91 lines
4.5 KiB
Python
91 lines
4.5 KiB
Python
"""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
|
|
|
|
GONE = "LB999999" # M01 에 없는 키(원본 지워짐)
|
|
|
|
|
|
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_원본_없는_항목_값_그대로_낡음_까닭_빠짐():
|
|
keys = ["EQ000004", GONE] # 불도저 · 조종원 · 경유(test_144 견본) + 원본 없는 키
|
|
old = _json(prices.refresh_book(["EQ000004"]))
|
|
kept = {"key": GONE, "code": "9999", "name": "지워진 직종", "price": 123.0}
|
|
old["rows"][GONE] = kept
|
|
old["rows"]["LB000048"] = {**old["rows"]["LB000048"], "price": 1} # M01 에서 바뀐 단가
|
|
assert prices.book_stale(old, keys) == "M01 에서 바뀐 단가 1" # 원본 없는 줄 = 까닭에 없음
|
|
new = _json(prices.refresh_book(keys, old))
|
|
assert new["rows"][GONE] == kept # 지우지도 바꾸지도 않음
|
|
assert new["rows"]["LB000048"]["price"] not in (None, 1) # 나머지 = 새로 굳힘
|
|
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 },\n true," in shell[at : at + 200]
|
|
assert 'if (!keep) clearState("b09-estimation", projectId);' in shell
|
|
assert "apply(next, !keep);" in shell
|