fix: 自有账号模式下仍可向账号池添加平台账号

This commit is contained in:
2026-10-30 11:27:04 +08:00
parent 7be1679d64
commit 90dbd1ddf7
2 changed files with 17 additions and 2 deletions
+15
View File
@@ -110,6 +110,21 @@ def test_local_login_task_and_admin(client: TestClient):
assert "小区" in downloaded.content.decode("utf-8-sig")
def test_pool_add_is_allowed_when_login_is_local(client: TestClient, monkeypatch):
from app.nqi.client import NqiError
async def fail_open(self):
raise NqiError("未连接平台")
monkeypatch.setattr("app.api.http.NqiClient.open_login", fail_open)
blocked = client.post("/api/auth/nqi/start", json={"username": "someone"})
assert blocked.status_code == 400
assert blocked.json()["detail"] == "当前使用自有账号登录"
pool = client.post("/api/auth/nqi/start", json={"username": "someone", "purpose": "pool"})
assert pool.status_code == 400
assert pool.json()["detail"] == "未连接平台"
def test_concurrency_bounds():
assert check_concurrency(1) == 1
assert check_concurrency(32) == 32