fix(pl): allow only etc recharge type in vehicle recharge schemas
Reject fuel writes so the shared module can be narrowed to ETC-only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
00849bd998
commit
542ecc63e7
2 files changed
+52
-3
No files matched your search
@@ -0,0 +1,49 @@
|
||||
"""车辆充值模块收窄为仅 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",
|
||||
}
|
||||
)
|
||||
Reference in new issue
Block a user