修复(账号分配): 隐藏停用客服并校验发放目标
分配概览只返回启用中的客服;停用用户不能出现在客服列表或作为定量发放目标。
This commit is contained in:
@@ -337,6 +337,45 @@ class TestAssignmentPools(_Base):
|
||||
assert skin["commodity_name"] == "选项皮肤"
|
||||
assert skin["account_count"] == 1
|
||||
|
||||
def test_assignment_summary_hides_inactive_support_users(self):
|
||||
inactive = User(
|
||||
username="deleted-support",
|
||||
password_hash="h",
|
||||
role="support",
|
||||
is_active=False,
|
||||
)
|
||||
self.session.add(inactive)
|
||||
self.session.commit()
|
||||
|
||||
result = assignments_summary(db=self.session, current=self.admin)
|
||||
|
||||
support_ids = {user["id"] for user in result["support_users"]}
|
||||
assert self.support.id in support_ids
|
||||
assert inactive.id not in support_ids
|
||||
|
||||
def test_dispatch_rejects_inactive_support(self):
|
||||
inactive = User(
|
||||
username="deleted-dispatch-target",
|
||||
password_hash="h",
|
||||
role="support",
|
||||
is_active=False,
|
||||
)
|
||||
self.session.add(inactive)
|
||||
self.session.commit()
|
||||
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
dispatch_assignments(
|
||||
AssignmentDispatch(
|
||||
assigned_to=inactive.id,
|
||||
quantity=1,
|
||||
),
|
||||
db=self.session,
|
||||
current=self.admin,
|
||||
)
|
||||
|
||||
assert exc_info.value.status_code == 400
|
||||
assert "已停用" in exc_info.value.detail
|
||||
|
||||
|
||||
class TestAllMatchingAssign(_Base):
|
||||
def test_assigns_every_matching_unassigned(self):
|
||||
|
||||
@@ -1459,7 +1459,7 @@ def assignments_summary(
|
||||
_assignable_account_filter(),
|
||||
),
|
||||
)
|
||||
.filter(User.role == "support")
|
||||
.filter(User.role == "support", User.is_active.is_(True))
|
||||
.group_by(User.id, User.username)
|
||||
.order_by(func.count(Account.id).desc())
|
||||
.all()
|
||||
|
||||
Reference in New Issue
Block a user