Files
shanxia2.0/backend/tests/test_vehicle_recharge_etc_only.py
T
wuzilongandCursor 542ecc63e7 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>
2026-09-12 08:43:49 +08:00

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",
}
)