""" backend/tests/test_freight_rpa_class_names.py 用途:锁住货代 RPA 模型的类名、表名和站点关系属性名。 依赖:app.models 里拆出的 freight_rpa_* 模型模块。 逻辑:被 pytest 直接导入;不连数据库。 """ from __future__ import annotations import app.models as models from app.models.freight_rpa_config import ( FreightRpaOnhandExternalMapping, FreightRpaOnhandReportConfig, FreightRpaSource, ) from app.models.freight_rpa_inbound_report import ( FreightRpaInboundReportConfig, FreightRpaInboundReportFile, FreightRpaInboundUnitRun, ) from app.models.freight_rpa_onhand_report_file import FreightRpaOnhandReportFile from app.models.freight_rpa_onhand_task_attempts import FreightRpaOnhandTaskAttempt def test_freight_rpa_classes_keep_existing_table_names(): """类名换成 FreightRpa 后,表名仍是规格里的 freight_rpa_*。""" assert FreightRpaSource.__tablename__ == "freight_rpa_sources" assert FreightRpaOnhandReportFile.__tablename__ == "freight_rpa_onhand_report_files" assert FreightRpaInboundReportFile.__tablename__ == "freight_rpa_inbound_report_files" assert FreightRpaInboundUnitRun.__tablename__ == "freight_rpa_inbound_rpa_unit_runs" def test_site_relationships_drop_inventory_and_receipt_names(): """站点关系改叫 source / inbound_report_config,索引名不在这个测试里改。""" assert "source" in FreightRpaOnhandReportConfig.__mapper__.relationships assert "inventory_source" not in FreightRpaOnhandReportConfig.__mapper__.relationships assert "source" in FreightRpaInboundReportConfig.__mapper__.relationships assert "source" in FreightRpaInboundUnitRun.__mapper__.relationships assert "inbound_report_config" in FreightRpaSource.__mapper__.relationships assert "receipt_report_config" not in FreightRpaSource.__mapper__.relationships assert "source" in FreightRpaOnhandExternalMapping.__mapper__.relationships assert FreightRpaOnhandTaskAttempt.__tablename__ == "freight_rpa_onhand_task_rpa_attempts" def test_old_shipping_class_names_are_not_exported(): """旧类名不留别名。发货任务关联类仍叫 ShippingTaskOnhandLink。""" assert not hasattr(models, "ShippingOnhandSource") assert not hasattr(models, "ShippingOnhandFile") assert not hasattr(models, "ShippingInboundReportFile") assert not hasattr(models, "ShippingParsingProfile") assert hasattr(models, "FreightRpaSource") assert hasattr(models, "FreightRpaOnhandReportFile") assert hasattr(models, "ShippingTaskOnhandLink") assert hasattr(models, "ShippingUploadAttempt")