Files
Aislo/resources/tester/test_733_2_library_ask.py
T
eomsangdonandClaude Opus 5.5 b4f8515b5d chore(853-2): 걸음 0 묶음 ① — 화면 0 서버 길 16 · 그 길만 부르던 본체 · 죽은 화면 래퍼 걷음
- 길: sangeun from-line · formula-check · copy · equation(셋) · block · labor copy · 프로젝트 양식 reset · apply · save-as · sources · drawing-import · drawing-fields · logic-lib machine-parts · logic-lib/auto
- 본체: Calc.from_line · Formula.check_doc 외 셋 · Equation 읽기 · 미리 셈 · Equation_Full 파일 · Block 끊기 · 잇기 · 수식 탭 · Labor_Copy.preview · Router_Layers 가져오기 도우미
- 화면: Api_Fetch 래퍼 여덟 · sangeunFromLine
- 시험: 죽은 길만 보던 796-2c · 796-2e 파일 지움 · 함수째 지움(715-3 · 733-2 · 792-1 · 796-2b · router_drawing · template_layers · structure_panel 글자 시험) · 살아 있는 결과는 [저장] 길로 고침(795-2 · 796-2b) · 813-2 = M01 parts.of_machine 바로
- 남김: Sangeun_Copy.preview(옛 엔진 셈 거울 — 걸음 2) · B07 이 쓰는 reset_project · B09 가 쓰는 _company_projects
- 검증: /openapi.json 524 → 508(뜻한 16 만) · 빌더 --check 같음 · 핵심 시험 99 통과 · 관련 시험 687 통과 · typecheck 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:36:15 +09:00

100 lines
5.1 KiB
Python

"""사람 길 만들 때 물음(PLAN 733-2 · `M02_Library_Ask`) — 임시 storage.
같은 층 같은 내용 = 409 `{같은것: [{키, 이름, 층, 주인}], 까닭}` →
`씀` = 새 문서 0 · `새로` = 새 문서 1.
길 = 새로 만들기 · [단가산출로 저장] from-line · 공유 요청 승인 · 복사 딸림 재사용(carry) ·
빈 문서 · 같은 층 복사 = 안 물음. B09 내 자료집 = `test_703_b09_daega_copy` · 구조물 조합으로 =
`test_705_2_hopyo_paste`.
"""
from __future__ import annotations
from M02_MasterTemplete import M02_Labor_Ref as refs
from M02_MasterTemplete import M02_MasterTemplete_Store as store
from M02_MasterTemplete import M02_Template_Layers as layers
from resources.tester import test_706_1_share_request as share_t
from resources.tester.test_706_1_share_request import URL, _as, _client
world = share_t.world # 같은 임시 storage 판
TEN = "GC000421"
STONE = "GF000219"
LIB = "/api/m02/layers/{}/library/{}"
def _count(folder, kind="precombo") -> int:
return len(list((folder / kind).glob("S?-*.json")))
def _doc(name: str, code: str = TEN) -> dict:
return {"문서": {"이름": name, "단위": "㎡", "담은로직": [{"로직": code}]}}
def test_새로_만들기_같은_내용_409_씀_새로(world):
client = _client(world)
_as(world)
mine = layers.personal_dir(7, 42)
url = LIB.format("personal", "precombo")
first = client.post(url, json=_doc("가")).json()["이름"]
res = client.post(url, json=_doc("이름 다름")) # 이름이 달라도 같은 내용
assert res.status_code == 409, res.text
detail = res.json()["detail"]
assert detail["같은것"] == [{"키": first, "이름": "가", "층": "personal", "주인": "7/42"}]
assert detail["까닭"]
used = client.post(url, json={**_doc("이름 다름"), "씀": first}).json()
assert used == {"이름": first, "씀": True} and _count(mine) == 1 # 그것을 씀 = 새 0
made = client.post(url, json={**_doc("이름 다름"), "새로": True}).json()["이름"]
assert made != first and _count(mine) == 2 # 그래도 새로 = 새 1
bad = client.post(url, json={**_doc("다른 것", STONE), "씀": first})
assert bad.status_code == 409 and _count(mine) == 2 # 같은 내용 아닌 키 = 다시 물음
assert client.post(url, json=_doc("다른 것", STONE)).status_code == 200 # 다른 내용 = 그대로
for _ in range(2): # 빈 새 문서 = 지문 없음 · 안 물음
empty = client.post(url, json={"문서": {"이름": "빈", "담은로직": []}})
assert empty.status_code == 200, empty.text
copy = {"본뜬": {"층": "personal", "주인": "7/42", "키": first}}
assert client.post(url, json=copy).status_code == 200 # 같은 층 [복사] = 안 물음
def test_공유_승인_회사_같은_내용_409_씀_새로(world):
client = _client(world)
_as(world)
pre = client.post(LIB.format("personal", "precombo"), json=_doc("내 것")).json()["이름"]
rid = client.post(URL, json={"종류": "precombo", "키": pre}).json()["id"]
_as(world, "ADMIN", user=50)
company = layers.company_dir(7)
have = client.post(LIB.format("company", "precombo"), json=_doc("회사 것")).json()["이름"]
res = client.post(f"{URL}/{rid}/approve", json={"경로": []})
assert res.status_code == 409 and res.json()["detail"]["같은것"][0]["키"] == have
assert client.get(URL).json()["줄"][0]["상태"] == "요청" # 물음 뒤 그대로
ok = client.post(f"{URL}/{rid}/approve", json={"경로": [], "씀": have}).json()
assert ok["상태"] == "승인" and ok["사본"] == have and _count(company) == 1
_as(world)
rid = client.post(URL, json={"종류": "precombo", "키": pre}).json()["id"]
_as(world, "ADMIN", user=50)
ok = client.post(f"{URL}/{rid}/approve", json={"경로": [], "새로": True}).json()
assert ok["사본"] != have and _count(company) == 2
def test_복사_딸림_같은_원본_재사용(world):
"""구조물 조합 복사 딸림(733-2) = 같은 원본 사본 재사용 · 740-1 — 일위대가 안 일위대가는
넣을 때 사본 블록(딸림 없음)."""
client = _client(world)
_as(world)
url = LIB.format("personal", "precombo")
inner = client.post(url, json=_doc("안")).json()["이름"]
ref = {"층": "personal", "주인": "7/42", "키": inner}
outer = {"문서": {"이름": "밖", "단위": "㎡", "담은로직": [{"참조": ref}]}}
top = client.post(url, json=outer).json()["이름"]
with store.at(layers.personal_dir(7, 42)):
assert store.read("precombo", top)["문서"]["담은로직"][0]["참조"]["층"] == "사본"
company = layers.company_dir(7)
combo = {"종류": "일위대가", "열": "rv", "담은로직": [{"참조": ref}], "자재": []}
with store.at(company):
one = refs.carry(combo, ("personal", "7/42"))
assert _count(company) == 1 # 딸린 안 = 회사 새 키
two = refs.carry(combo, ("personal", "7/42"))
assert _count(company) == 1 # 다시 복사 = 앞 사본 재사용
got = [x["담은로직"][0]["참조"] for x in (one, two)]
assert got[0] == got[1] and got[0]["층"] == "company"