test_pl_vehicle_personnel_photo_schema.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """车辆/人员 Schema 接受 photoUrls。"""
  2. from __future__ import annotations
  3. from app.schemas.pl.base_data import PersonnelCreate, PersonnelUpdate, VehicleCreate, VehicleUpdate
  4. def test_vehicle_create_accepts_photo_urls():
  5. body = VehicleCreate.model_validate(
  6. {
  7. "vehicleType": "carrier",
  8. "licensePlate": "皖A12345",
  9. "vehicleStatus": "available",
  10. "photoUrls": "pl/vehicle-photo/a.jpg",
  11. }
  12. )
  13. assert body.photo_urls == "pl/vehicle-photo/a.jpg"
  14. def test_vehicle_update_accepts_photo_urls():
  15. body = VehicleUpdate.model_validate({"photoUrls": "pl/vehicle-photo/b.jpg"})
  16. assert body.photo_urls == "pl/vehicle-photo/b.jpg"
  17. def test_personnel_create_accepts_photo_urls():
  18. body = PersonnelCreate.model_validate(
  19. {
  20. "personnelName": "张三",
  21. "personnelType": "driver",
  22. "personnelAffiliation": "self",
  23. "status": "1",
  24. "photoUrls": "pl/personnel-photo/c.jpg",
  25. }
  26. )
  27. assert body.photo_urls == "pl/personnel-photo/c.jpg"
  28. def test_personnel_update_accepts_photo_urls():
  29. body = PersonnelUpdate.model_validate({"photoUrls": ""})
  30. assert body.photo_urls == ""