feat(733-2): 사람 길 만들 때 같은 내용 409 물음 · 복사 딸림 재사용
- 새 M02_Library_Ask — 같은 층 같은 내용(733-1 지문) = 409 {같은것: [{키, 이름, 층, 주인}], 까닭} · 몸 새로 = 그래도 새로 · 씀 = 그 키(새 문서 0 · 같은 내용 아닌 키 = 다시 409)
- 길 = 새로 만들기(빈 문서 · 같은 층 복사 = 안 물음) · [단가산출로 저장] from-line · B09 내 자료집(같은이름 409 와 한 몸 · 하위 호표 지문 = 굳힌 문서) · 공유 요청 승인(일위대가 · 씀 = 사본 키) · 실무 호표 [구조물 조합으로](구조물 조합 지문 = 줄 수량 넣음)
- 복사 딸림 carry — 받는 층에 같은 원본 + 같은 내용 사본이 있으면 그 키 재사용(refs.copied_from) · B09 하위 호표 재사용 목록 = 실무자료 한정 → 모든 사본 원본
- 낡은 시험 고침: test_703 자료집 같은 이름 물음 — 새 이름이라도 같은 내용이면 409(정함 3장 3) → new=True 로 새로 · 씀 확인 더함
- 새 시험 test_733_2_library_ask(새로 · from-line · 승인 · carry) · test_705_2 구조물 조합으로 409
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -174,7 +174,14 @@ def test_자료집_같은_이름_물음(world):
|
||||
changed["담은로직"][1]["수량"] = {"손": 9}
|
||||
again = personal.write(changed, first["이름"]) # 덮어쓰기
|
||||
assert again["이름"] == first["이름"]
|
||||
other = personal.write({**doc, "이름": "내 돌붙임 2"}) # 새 이름
|
||||
with pytest.raises(m02.StoreError) as e: # 733-2 — 새 이름이라도 같은 내용 = 409 물음
|
||||
personal.write({**doc, "이름": "내 돌붙임 2"})
|
||||
assert (
|
||||
e.value.detail["같은것"][0]["키"] == first["이름"] and "같은이름" not in e.value.detail
|
||||
)
|
||||
other = personal.write({**doc, "이름": "내 돌붙임 2"}, new=True) # 그래도 새로
|
||||
used = personal.write({**doc, "이름": "내 돌붙임 3"}, use=first["이름"]) # 그것을 씀
|
||||
assert used == {"이름": first["이름"], "씀": True}
|
||||
assert other["이름"] != first["이름"]
|
||||
saved = json.loads(
|
||||
(world["folder"] / "precombo" / f"{first['이름']}.json").read_text(encoding="utf-8")
|
||||
|
||||
@@ -359,6 +359,22 @@ def test_구조물_조합으로_남의_층_403(client):
|
||||
assert client.post("/api/m02/layers/company/hopyo-item", json=body).status_code == 403
|
||||
|
||||
|
||||
def test_구조물_조합으로_같은_내용_409_씀_새로(client):
|
||||
"""733-2 — 이 층 같은 내용 항목 = 409 `{같은것}` → `씀` = 새 항목 0 · `새로` = 새 항목 1."""
|
||||
key = _upload(client, "대흥")
|
||||
url, body = "/api/m02/layers/personal/hopyo-item", {"층": "personal", "키": key, "번": 17}
|
||||
first = client.post(url, json=body).json()
|
||||
count = len(list((layers_dir() / "labor").glob("*.json")))
|
||||
res = client.post(url, json=body)
|
||||
assert res.status_code == 409 and res.json()["detail"]["같은것"][0]["키"] == first["열"]
|
||||
used = client.post(url, json={**body, "씀": first["열"]}).json()
|
||||
assert used["열"] == first["열"] and used["씀"] is True
|
||||
assert len(list((layers_dir() / "labor").glob("*.json"))) == count
|
||||
made = client.post(url, json={**body, "새로": True}).json()
|
||||
assert made["열"] != first["열"]
|
||||
assert len(list((layers_dir() / "labor").glob("*.json"))) == count + 1
|
||||
|
||||
|
||||
def test_규격_열_이름():
|
||||
from M02_MasterTemplete import M02_Hopyo_Item as item
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
"""사람 길 만들 때 물음(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):
|
||||
client = _client(world)
|
||||
_as(world)
|
||||
mine = layers.personal_dir(7, 42)
|
||||
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(mine):
|
||||
doc = store.read("precombo", top)["문서"]
|
||||
src = {"층": "personal", "주인": "7/42", "키": top}
|
||||
company = layers.company_dir(7)
|
||||
with store.at(company):
|
||||
one = refs.create("precombo", refs.carry(refs.origin_mark(doc, src), ("personal", "7/42")))
|
||||
assert _count(company) == 2 # 밖 + 딸린 안
|
||||
two = refs.create("precombo", refs.carry(refs.origin_mark(doc, src), ("personal", "7/42")))
|
||||
assert _count(company) == 3 # 다시 복사 = 밖만 새로 · 딸린 안 = 앞 사본 재사용
|
||||
with store.at(company):
|
||||
got = [store.read("precombo", m["이름"])["문서"]["담은로직"][0]["참조"] for m in (one, two)]
|
||||
assert got[0] == got[1] and got[0]["층"] == "company"
|
||||
Reference in New Issue
Block a user