49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
"""挂车号分流:货拉拉免挂车证;自有正常挂车号强制;三方不强制。"""
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from fastapi import HTTPException
|
|
|
|
from app.services.pl_cert_required_service import (
|
|
is_huolala_trailer_no,
|
|
should_require_trailer_certs,
|
|
should_show_trailer_cert_slots,
|
|
validate_self_vehicle_required_certs,
|
|
)
|
|
|
|
|
|
def _complete_self_head_certs():
|
|
return [
|
|
{"cert_name": "行驶证", "expire_date": "2030-01-01", "vehicle_part": "head"},
|
|
{"cert_name": "营运证", "expire_date": "2030-01-01", "vehicle_part": "head"},
|
|
{"cert_name": "保险单", "expire_date": "2030-01-01", "vehicle_part": "head"},
|
|
]
|
|
|
|
|
|
def test_huolala_trailer_helpers():
|
|
assert is_huolala_trailer_no("货拉拉")
|
|
assert is_huolala_trailer_no(" 货拉拉 ")
|
|
assert not is_huolala_trailer_no("皖LP359")
|
|
assert not should_show_trailer_cert_slots("货拉拉")
|
|
assert should_show_trailer_cert_slots("皖LP359")
|
|
assert not should_require_trailer_certs("self", "货拉拉")
|
|
assert should_require_trailer_certs("self", "皖LP359")
|
|
assert not should_require_trailer_certs("carrier", "皖LP359")
|
|
|
|
|
|
def test_self_huolala_skips_trailer_required_certs():
|
|
validate_self_vehicle_required_certs(
|
|
_complete_self_head_certs(),
|
|
trailer_no="货拉拉",
|
|
)
|
|
|
|
|
|
def test_self_normal_trailer_requires_trailer_certs():
|
|
with pytest.raises(HTTPException) as ei:
|
|
validate_self_vehicle_required_certs(
|
|
_complete_self_head_certs(),
|
|
trailer_no="皖LP359",
|
|
)
|
|
assert ei.value.status_code == 400
|
|
assert "挂车" in ei.value.detail
|