test(withdraw): 测试健壮性 polish(openid 取自 User + 补 status_code 断言)

This commit is contained in:
guke
2026-07-23 18:28:51 +08:00
parent 07cf806805
commit d872755bb8
+3 -1
View File
@@ -438,7 +438,7 @@ def _seed_transfer_auth(phone: str, state: str, authorization_id: str | None) ->
auth = db.get(WechatTransferAuthorization, user.id)
if auth is None:
auth = WechatTransferAuthorization(
user_id=user.id, openid="openid_test_abc",
user_id=user.id, openid=user.wechat_openid or "openid_test_abc",
out_authorization_no=f"oan_{user.id}",
)
db.add(auth)
@@ -465,6 +465,7 @@ def test_withdraw_info_auth_enabled_requires_authorization_id(client, monkeypatc
# active 且有 authorization_id → 已授权
_seed_transfer_auth("13800002051", "active", "wx_auth_123")
r = client.get("/api/v1/wallet/withdraw-info", headers=_auth(token))
assert r.status_code == 200, r.text
assert r.json()["transfer_auth_enabled"] is True
@@ -482,4 +483,5 @@ def test_transfer_auth_status_requires_authorization_id(client, monkeypatch) ->
_seed_transfer_auth("13800002052", "active", "wx_auth_456")
r = client.get("/api/v1/wallet/transfer-auth/status", headers=_auth(token))
assert r.status_code == 200, r.text
assert r.json()["enabled"] is True