"""CRM 产品读模型契约测试。""" from __future__ import annotations from app.crud.crm.product import _product_row_to_dict from app.models.crm_models import CrmProduct from app.schemas.crm.product import ProductCreateBody, ProductUpdateBody def test_product_read_contract_exposes_creator_for_delete_permission(): row = CrmProduct( id="product-1", product_no="CP-001", product_name="工业甲醇", create_by="user-1", ) payload = _product_row_to_dict(row) assert payload["createBy"] == "user-1" def test_product_creator_stays_read_only_in_write_schemas(): assert "create_by" not in ProductCreateBody.model_fields assert "create_by" not in ProductUpdateBody.model_fields