o2o-negosium-original/negodata/backend/tests/test_features.py
Mina Choi 1f778ab975 [feat] negodata/backend: 상품·협력사·견적 도메인 CRUD + delivery_type 코드화 + 공용 /v1/enums
- item/supplier/quotation/quotation_setting CRUD·service·router 추가
- item protocol delivery_type str→int (ERD/스키마 SMALLINT 일치)
- DeliveryType enum + 한글 라벨, 공용 GET /v1/enums (도메인 코드 메타데이터)
- CompanyBrief → CompanyData 로 *Data 네이밍 통일
- CORS: WebServerConfig.client_url(단일) 도입 (config_models/router)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 15:58:38 +09:00

69 lines
2.4 KiB
Python

"""supplier / quotation_setting / quotation 슬라이스 런타임 스모크.
create(재조회로 created_at 적재) + list + get 경로를 라이브 DB 로 확인한다.
"""
import uuid
async def _headers(client, company_id, login_id):
await client.post(
"/v1/auth/create",
json={"id": login_id, "password": "pw1234", "company_id": company_id, "name": "n"},
)
r = await client.post("/v1/auth/login", json={"id": login_id, "password": "pw1234"})
return {"Authorization": f"Bearer {r.json()['access_token']}"}
async def test_supplier_crud(client, company_id):
h = await _headers(client, company_id, "supuser")
r = await client.post("/v1/supplier/create", json={"name": "공급사A", "code": "S1"}, headers=h)
body = r.json()
assert body["result"]["success"] is True
sup = body["supplier"]
assert sup["name"] == "공급사A"
assert sup["created_at"] # 재조회 픽스: 서버 기본값 적재 확인
sid = sup["supplier_id"]
r = await client.get("/v1/supplier/list", headers=h)
assert r.json()["total"] == 1
r = await client.get(f"/v1/supplier/{sid}", headers=h)
assert r.json()["supplier"]["supplier_id"] == sid
async def test_quotation_setting_crud(client, company_id):
h = await _headers(client, company_id, "qsuser")
r = await client.post("/v1/quotation-setting/create", json={"target_margin_rate": 0.15}, headers=h)
body = r.json()
assert body["result"]["success"] is True
st = body["setting"]
assert st["target_margin_rate"] == 0.15
assert st["card_count"] == 3 # 기본값
assert st["created_at"]
r = await client.get("/v1/quotation-setting/list", headers=h)
assert r.json()["total"] >= 1
async def test_quotation_create(client, company_id):
h = await _headers(client, company_id, "qtuser")
body = {
"qt_setting_id": str(uuid.uuid4()),
"version_id": str(uuid.uuid4()),
"name": "견적A",
"number": "Q-001",
"type": "재견적",
"status": "진행중",
"start_time": "2026-06-16T00:00:00",
"end_time": "2026-06-17T00:00:00",
}
r = await client.post("/v1/quotation/create", json=body, headers=h)
res = r.json()
assert res["result"]["success"] is True
q = res["quotation"]
assert q["name"] == "견적A"
assert q["created_at"] # 재조회 픽스
r = await client.get("/v1/quotation/list", headers=h)
assert r.json()["total"] >= 1