Merge remote-tracking branch 'origin/sub_laptop_7' into sub_laptop_6
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
"""일위대가 ↔ 면적산출 함께 가져오기(PLAN 43-9a) · 새 항목 = 칸 셋 자동 생성.
|
||||
|
||||
시스템 층 = 견본 표(임시 폴더) · 개인 층 = 임시 storage (`test_m02_labor_copy` 의 world 를 씀).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from resources.tester.test_m02_labor_copy import (
|
||||
TEN,
|
||||
URL,
|
||||
_as,
|
||||
world, # noqa: F401 — 고정물
|
||||
)
|
||||
|
||||
|
||||
def _doc(folder: Path, kind: str, cid: str) -> dict:
|
||||
return json.loads((folder / kind / f"{cid}.json").read_bytes())
|
||||
|
||||
|
||||
def _link_rv(system: Path) -> None:
|
||||
"""원본 rv — 일위대가 수량은 알약 연결 · 면적산출 B6 = 5 에 그 알약."""
|
||||
with store.at(system):
|
||||
got = store.read("labor", "rv")
|
||||
rows = [{"로직": TEN, "입력값": {}, "수량": None}]
|
||||
store.write("labor", "rv", got["판"], {**got["문서"], "담은로직": rows})
|
||||
pill = labor.pills(store.read("labor", "rv")["문서"])[0]["키"]
|
||||
area = store.read("area", "rv")
|
||||
sheet = area["문서"]["시트"][0]
|
||||
sheet["칸"] = {"B6": {"값": "5"}}
|
||||
sheet["연결"] = [{"키": pill, "이름": "x", "칸": "B6", "단위": "㎡"}]
|
||||
store.write("area", "rv", area["판"], area["문서"])
|
||||
|
||||
|
||||
def test_새_항목_칸_셋_빈_문서_자동_같은_뒷자리(world): # noqa: F811
|
||||
personal = world["personal"]
|
||||
numbers = [_doc(personal, k, "a")[key] for k, key in store._KEY.items()]
|
||||
assert [n[:2] for n in numbers] == ["SD", "SU", "SA"]
|
||||
assert len({n[2:] for n in numbers}) == 1
|
||||
assert _doc(personal, "labor", "a")["담은로직"] == []
|
||||
|
||||
|
||||
def test_일위대가_면적산출_함께_덮어씀_도면은_그대로(world): # noqa: F811
|
||||
system, personal = world["system"], world["personal"]
|
||||
_link_rv(system)
|
||||
before = {k: _doc(personal, k, "a") for k in ("structure", "labor", "area")}
|
||||
for kind in ("labor", "area"): # 어느 카드에서 불러도 같음
|
||||
url = URL.format("personal", kind, "a") + "?from=rv&from_layer=system&pair=true"
|
||||
got = _as(world).post(url)
|
||||
assert got.status_code == 200 and set(got.json()) == {"area", "labor"}
|
||||
area, doc = _doc(personal, "area", "a"), _doc(personal, "labor", "a")
|
||||
assert area["시트"][0]["연결"][0]["칸"] == "B6" and area["면적번"] == before["area"]["면적번"]
|
||||
assert (doc["담은로직"][0]["로직"], doc["일위대가번"]) == (TEN, before["labor"]["일위대가번"])
|
||||
line = doc["계산값"]["줄"][0]
|
||||
assert (line["수량"], line["수량출처"]) == (5, "칸") # 새 면적 칸 값으로 셈
|
||||
assert _doc(personal, "structure", "a") == before["structure"]
|
||||
|
||||
|
||||
def test_pair_없으면_예전처럼_한_칸만(world): # noqa: F811
|
||||
system, personal = world["system"], world["personal"]
|
||||
_link_rv(system)
|
||||
url = URL.format("personal", "labor", "a") + "?from=rv&from_layer=system"
|
||||
assert _as(world).post(url).status_code == 200
|
||||
assert "연결" not in _doc(personal, "area", "a")["시트"][0]
|
||||
|
||||
|
||||
def test_실무문서는_일위대가만_면적_그대로(world): # noqa: F811
|
||||
system = world["system"]
|
||||
_link_rv(system)
|
||||
area = _doc(system, "area", "rv")
|
||||
for kind in ("labor", "area"):
|
||||
url = URL.format("system", kind, "rv") + "?from=UA000008&from_layer=practice&pair=true"
|
||||
assert _as(world).post(url).status_code == 403 # 시스템 관리자만
|
||||
got = _as(world, "SYSTEM_ADMIN").post(url)
|
||||
assert got.status_code == 200 and set(got.json()) == {"labor"}
|
||||
assert len(_doc(system, "labor", "rv")["담은로직"]) == 14
|
||||
assert _doc(system, "area", "rv") == area
|
||||
|
||||
|
||||
def test_원본에_면적산출_없으면_일위대가만(world): # noqa: F811
|
||||
system, personal = world["system"], world["personal"]
|
||||
(system / "area" / "rv.json").unlink()
|
||||
area = _doc(personal, "area", "a")
|
||||
url = URL.format("personal", "area", "a") + "?from=rv&from_layer=system&pair=true"
|
||||
got = _as(world).post(url)
|
||||
assert got.status_code == 200 and set(got.json()) == {"labor"}
|
||||
assert _doc(personal, "area", "a") == area
|
||||
assert _doc(personal, "labor", "a")["담은로직"][0]["로직"] == TEN
|
||||
Reference in New Issue
Block a user