39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
|
|
"""审批管理入参校验(schema 层,秒级)。
|
|||
|
|
|
|||
|
|
守的是:对象类型筛选必须覆盖三类审批对象(1 二次分配方案 / 2 月度结算 /
|
|||
|
|
3 调整单)——早期上界写死在 2,调整单审批单在列表里无法筛选;越界值在
|
|||
|
|
参数绑定阶段即拒绝。驳回必须带意见(空驳无从追溯)。
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
import pytest
|
|||
|
|
from pydantic import ValidationError
|
|||
|
|
|
|||
|
|
from app.schemas.approval import ApprovalActionIn, ApprovalQuery
|
|||
|
|
|
|||
|
|
|
|||
|
|
class TestQueryOrderType:
|
|||
|
|
"""对象类型筛选边界。"""
|
|||
|
|
|
|||
|
|
@pytest.mark.parametrize("value", [1, 2, 3])
|
|||
|
|
def test_三类对象均可筛选(self, value: int) -> None:
|
|||
|
|
assert ApprovalQuery(order_type=value).order_type == value
|
|||
|
|
|
|||
|
|
@pytest.mark.parametrize("value", [0, 4])
|
|||
|
|
def test_越界类型被拒(self, value: int) -> None:
|
|||
|
|
with pytest.raises(ValidationError):
|
|||
|
|
ApprovalQuery(order_type=value)
|
|||
|
|
|
|||
|
|
def test_不传类型表示全部(self) -> None:
|
|||
|
|
assert ApprovalQuery().order_type is None
|
|||
|
|
|
|||
|
|
|
|||
|
|
class TestActionOpinion:
|
|||
|
|
"""节点动作的驳回意见要求。"""
|
|||
|
|
|
|||
|
|
def test_驳回必须填意见(self) -> None:
|
|||
|
|
with pytest.raises(ValidationError):
|
|||
|
|
ApprovalActionIn(action=2)
|
|||
|
|
|
|||
|
|
def test_通过可不填意见(self) -> None:
|
|||
|
|
assert ApprovalActionIn(action=1).opinion is None
|