Files
Aislo/resources/tester/test_733_2_library_ask.py
T
eomsangdonandClaude Opus 5.5 6893599fa9 feat(740-1): 일위대가 안 일위대가 = 사본 블록(원본 연결 끊음 · 하위 호표 끝수 그대로) · 초기화 이음 기계 다시 받음
- SC 안 SC = 안쪽 SC 몸 통째를 그 줄 참조 꼴 {층: 사본, 주인: 몸 지문, 키: 본 SC, 몸} 에 담음(Labor_Ref.copy_ref · read_ref 가 몸을 돌려줌 → 셈 · 알약 · B09 하위 대가 블록 · 지문 = 옛 참조 줄과 같은 길) · 엑셀 대조 거창 같음 14 그대로 · 같은 기초 겹침도 블록 안(400 없음)
- 저장 · 읽기 · 옮기기 · 찾아 넣기 모두 사본 블록 · 자기 자신을 담은 줄 = 안 펼침(저장 422 그대로)
- 단가산출에 SC 넣기 = 사본 블록 줄도 더한줄로 펼침(바깥 × 안 수량)
- 초기화 = 사본 몸 안까지 · 이음 기계 고정 줄(736-3) 단가 = M01 기계 한 시간 값 다시 받음
- 옮기기 = 쓰는 곳 검사 걷음(같은 자리 한 줄이라 안 줄 알약 차례 그대로) · 실 storage 보기만 = 1/3 SC-000002 사본 블록 · 전후 1,446,078 같음
- 낡은 시험 고침(까닭 = 하위 호표 참조가 사본 블록으로): m02_labor_ref(순환 대신 사본 · 복사 딸림 없음) · 733-2(딸림 재사용 = 구조물 조합 복사) · 735-1(쓰는 곳 = 구조물 조합 둘) · hopyo_build · 707-7(하위 호표 줄 = 사본 블록 · 본뜬)

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

116 lines
5.9 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
import pytest
from M02_MasterTemplete import M02_Labor_Ref as refs
from M02_MasterTemplete import M02_MasterTemplete_Store as store
from M02_MasterTemplete import M02_Sangeun_Calc as calc
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):
mine = layers.personal_dir(7, 42)
line = {"로직": TEN, "수량": {"손": 2}, "별칭": "내 줄"}
with store.at(mine):
first = calc.from_line(line, "줄로 만든", "㎡")
with pytest.raises(store.StoreError) as e:
calc.from_line(line, "또 만든", "㎡")
assert e.value.status == 409 and e.value.detail["같은것"][0]["키"] == first["이름"]
used = calc.from_line(line, "또 만든", "㎡", use=first["이름"])
assert used == first and _count(mine, "sangeun") == 1 # 줄 = 그 SK 참조
made = calc.from_line(line, "또 만든", "㎡", new=True)
assert made["이름"] != first["이름"] and _count(mine, "sangeun") == 2
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"