整合合同费用并移除旧财务合同
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
"""合同费用基础字段测试"""
|
||||
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
"""旧合同基础信息模块移除测试"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def test_api_router_no_longer_registers_legacy_finance_contracts():
|
||||
router_source = (ROOT / "app" / "api" / "v1" / "router.py").read_text()
|
||||
|
||||
assert "finance_contracts" not in router_source
|
||||
assert "finance-contracts" not in router_source
|
||||
|
||||
|
||||
def test_active_backend_code_no_longer_imports_finance_contract_model():
|
||||
checked_paths = [
|
||||
ROOT / "app" / "db" / "base.py",
|
||||
ROOT / "app" / "crud" / "study.py",
|
||||
ROOT / "app" / "crud" / "site.py",
|
||||
ROOT / "app" / "crud" / "overview.py",
|
||||
]
|
||||
|
||||
for path in checked_paths:
|
||||
assert "FinanceContract" not in path.read_text()
|
||||
Reference in New Issue
Block a user