fix(login): 中文提示登录批次账号上限
This commit is contained in:
@@ -5,15 +5,20 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
from datetime import UTC, datetime
|
||||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
|
||||
from tests.support.db import get_test_engine, make_test_session
|
||||
from web.backend.models import Account, LoginTask, User
|
||||
from web.backend.routers.login import (
|
||||
create_batch,
|
||||
delete_tasks,
|
||||
export_tasks,
|
||||
list_tasks,
|
||||
task_filter_options,
|
||||
tasks_summary,
|
||||
)
|
||||
from web.backend.schemas import LOGIN_BATCH_MAX_ACCOUNTS, LoginBatchRequest
|
||||
|
||||
NOW = datetime(2026, 11, 20, 12, 0, 0, tzinfo=UTC)
|
||||
|
||||
@@ -188,3 +193,18 @@ class TestLoginTaskFilters:
|
||||
assert result["deleted"] == 1
|
||||
assert self.db.get(LoginTask, task_b_id) is None
|
||||
assert self.db.get(LoginTask, task_a_id) is not None
|
||||
|
||||
def test_batch_login_over_limit_returns_chinese_message(self):
|
||||
requested = LOGIN_BATCH_MAX_ACCOUNTS + 37
|
||||
req = LoginBatchRequest(account_ids=list(range(1, requested + 1)))
|
||||
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
asyncio.run(create_batch(req, db=self.db, current=self.admin))
|
||||
|
||||
assert exc_info.value.status_code == 400
|
||||
assert (
|
||||
f"单次最多选择 {LOGIN_BATCH_MAX_ACCOUNTS} 个账号"
|
||||
in str(exc_info.value.detail)
|
||||
)
|
||||
assert f"当前选择了 {requested} 个" in str(exc_info.value.detail)
|
||||
assert "请分批操作" in str(exc_info.value.detail)
|
||||
|
||||
Reference in New Issue
Block a user