Reject fuel writes so the shared module can be narrowed to ETC-only. Co-authored-by: Cursor <cursoragent@cursor.com>
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
"""车辆充值模块收窄为仅 ETC。"""
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from app.schemas.pl.vehicle_recharge import (
|
|
RECHARGE_TYPES,
|
|
VehicleRechargeApplyCreate,
|
|
VehicleRechargeRecordCreate,
|
|
)
|
|
|
|
|
|
def test_recharge_types_only_etc():
|
|
assert RECHARGE_TYPES == {"etc"}
|
|
|
|
|
|
def test_apply_create_rejects_fuel():
|
|
with pytest.raises(ValidationError):
|
|
VehicleRechargeApplyCreate.model_validate(
|
|
{
|
|
"licensePlate": "鄂A12345",
|
|
"rechargeType": "fuel",
|
|
"applyDate": "2026-09-12",
|
|
}
|
|
)
|
|
|
|
|
|
def test_apply_create_accepts_etc():
|
|
obj = VehicleRechargeApplyCreate.model_validate(
|
|
{
|
|
"licensePlate": "鄂A12345",
|
|
"rechargeType": "etc",
|
|
"applyDate": "2026-09-12",
|
|
}
|
|
)
|
|
assert obj.recharge_type == "etc"
|
|
|
|
|
|
def test_record_create_rejects_fuel():
|
|
with pytest.raises(ValidationError):
|
|
VehicleRechargeRecordCreate.model_validate(
|
|
{
|
|
"rechargeDate": "2026-09-12",
|
|
"rechargeType": "fuel",
|
|
"amount": "100.00",
|
|
"licensePlate": "鄂A12345",
|
|
}
|
|
)
|