o2o-negosium-original/negodata/backend/tests/test_features.py
Mina Choi f19c6f57ea [chore] negodata: enum 주석 영문값 보강 + 견적상태 3종 정리 + 대시보드 정비
- enum DDL 주석에 영문값 보강(status/role/delivery/usage_type/qt_type/supplier_type)
- 견적상태 3종(생성/진행중/마감)으로 정리(ON_HOLD 제거), 배송 PARTNER→SUPPLIER
- 대시보드 손질, 관련 테스트·negosium 견적유형 주석 동반

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

76 lines
2.8 KiB
Python

"""supplier / quotation_setting / quotation 슬라이스 런타임 스모크.
create(재조회로 created_at 적재) + list + get 경로를 라이브 DB 로 확인한다.
"""
import uuid
from common.enums import QuotationStatus, QuotationType
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")
# type/status 는 int 코드(QuotationType/QuotationStatus). number 는 서버가 생성하므로 미전송.
body = {
"qt_setting_id": str(uuid.uuid4()),
"version_id": str(uuid.uuid4()),
"name": "견적A",
"type": QuotationType.REQUOTE.value,
"status": QuotationStatus.IN_PROGRESS.value,
"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()
# 생성 응답은 본문(quotation)을 안 주고 qt_id/session_count 만 반환 → qt_id 로 재조회한다.
assert res["result"]["success"] is True
qt_id = res["qt_id"]
assert qt_id
r = await client.get(f"/v1/quotation/{qt_id}", headers=h)
q = r.json()["quotation"]
assert q["name"] == "견적A"
assert q["created_at"] # 재조회로 created_at 적재 확인
r = await client.get("/v1/quotation/list", headers=h)
assert r.json()["total"] >= 1