test_pl_facet_context.py 921 B

12345678910111213141516171819202122232425262728293031
  1. """PL 通用 facet 上下文剥离单测。"""
  2. from app.services.pl.facet_context import strip_simple_facet_self_params
  3. def test_strip_carrier_name():
  4. params = {
  5. "field": "carrierName",
  6. "limit": 500,
  7. "carrierNameIn": "甲",
  8. "contactNameIn": "张三",
  9. "statusIn": "1",
  10. "q": "搜",
  11. }
  12. out = strip_simple_facet_self_params(params, "carrierName")
  13. assert "carrierNameIn" not in out
  14. assert out["contactNameIn"] == "张三"
  15. assert out["statusIn"] == "1"
  16. assert out["q"] == "搜"
  17. assert "field" not in out
  18. def test_strip_keeps_vehicle_type():
  19. params = {
  20. "licensePlateIn": "浙A",
  21. "vehicleType": "self",
  22. "vehicleStatusIn": "1",
  23. }
  24. out = strip_simple_facet_self_params(params, "licensePlate")
  25. assert "licensePlateIn" not in out
  26. assert out["vehicleType"] == "self"
  27. assert out["vehicleStatusIn"] == "1"