51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
"""合同费用基础字段测试"""
|
|
|
|
from datetime import date
|
|
from decimal import Decimal
|
|
import uuid
|
|
|
|
from app.models.contract_fee import ContractFee
|
|
from app.schemas.contract_fee import ContractFeeCreate, ContractFeeRead, ContractFeeUpdate
|
|
|
|
|
|
def test_contract_fee_schema_includes_contract_basic_fields():
|
|
"""合同费用应包含合同基础信息字段。"""
|
|
project_id = uuid.uuid4()
|
|
center_id = uuid.uuid4()
|
|
|
|
payload = ContractFeeCreate(
|
|
project_id=project_id,
|
|
center_id=center_id,
|
|
contract_no="CT-001",
|
|
signed_date=date(2026, 5, 27),
|
|
contract_amount=Decimal("120000.00"),
|
|
currency="CNY",
|
|
remark="首版合同",
|
|
contract_cases=12,
|
|
)
|
|
|
|
assert payload.contract_no == "CT-001"
|
|
assert payload.signed_date == date(2026, 5, 27)
|
|
assert payload.currency == "CNY"
|
|
assert payload.remark == "首版合同"
|
|
|
|
update_payload = ContractFeeUpdate(contract_no="CT-002", currency="USD", remark="变更合同信息")
|
|
assert update_payload.model_dump(exclude_unset=True) == {
|
|
"contract_no": "CT-002",
|
|
"currency": "USD",
|
|
"remark": "变更合同信息",
|
|
}
|
|
|
|
for field in ("contract_no", "signed_date", "currency", "remark"):
|
|
assert field in ContractFeeRead.model_fields
|
|
|
|
|
|
def test_contract_fee_model_includes_contract_basic_columns():
|
|
"""合同费用模型应持久化合同基础信息。"""
|
|
columns = ContractFee.__table__.columns
|
|
|
|
assert "contract_no" in columns
|
|
assert "signed_date" in columns
|
|
assert "currency" in columns
|
|
assert "remark" in columns
|