This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""用户校验模型测试。"""
|
||||
import pytest
|
||||
|
||||
from modules.user.schemas import UserSchema, UserStatusSchema
|
||||
|
||||
|
||||
def test_user_create_minimal():
|
||||
form = UserSchema(
|
||||
realname="测试", gender=1, avatar="default.png",
|
||||
mobile="13800138000", email="test@example.com",
|
||||
deptId=0, levelId=0, positionId=0,
|
||||
address="测试地址", username="tester",
|
||||
status=1, sort=0,
|
||||
)
|
||||
assert form.gender == 1
|
||||
assert form.status == 1
|
||||
assert form.city is None
|
||||
|
||||
|
||||
def test_user_create_with_city_and_roles():
|
||||
form = UserSchema(
|
||||
realname="测试", gender=1, avatar="default.png",
|
||||
mobile="13800138000", email="test@example.com",
|
||||
deptId=0, levelId=0, positionId=0,
|
||||
address="测试地址", username="tester",
|
||||
status=1, sort=0,
|
||||
city=[110000, 110100, 110101],
|
||||
roles=[1, 2],
|
||||
)
|
||||
assert form.city == [110000, 110100, 110101]
|
||||
assert form.roles == [1, 2]
|
||||
|
||||
|
||||
def test_user_status_invalid():
|
||||
with pytest.raises(Exception):
|
||||
UserStatusSchema(id=0, status=1)
|
||||
|
||||
|
||||
def test_user_status_valid():
|
||||
form = UserStatusSchema(id=1, status=2)
|
||||
assert form.id == 1
|
||||
assert form.status == 2
|
||||
Reference in New Issue
Block a user