fix(weibo): 识别支付域登录失效

This commit is contained in:
yml2213
2026-11-08 14:06:26 +08:00
parent ed15701392
commit 7f7a8f6004
4 changed files with 86 additions and 3 deletions
+26 -1
View File
@@ -17,6 +17,7 @@ from core.weibo import (
WeiboExchangeUncertainError,
WeiboHomeSnapshot,
WeiboRechargeError,
WeiboTransportError,
extract_bind_raw_url,
normalize_weibo_cookie,
)
@@ -50,7 +51,7 @@ class FakeResponse:
def json(self):
if not isinstance(self.payload, dict):
raise TypeError("not json")
raise requests.exceptions.JSONDecodeError("not json", self.text, 0)
return self.payload
@@ -155,6 +156,30 @@ def test_fetch_home_keeps_trace_id_for_other_api_error():
client.fetch_home()
def test_fetch_home_treats_sina_login_redirect_as_auth_error():
session = FakeSession(
[
(
"<html><head><meta http-equiv='refresh' "
"content=\"0; url='https://vipclub.weibo.com/aj/vmember/"
"gfsupport?retcode=6102'\"></head></html>"
)
]
)
client = WeiboClient("SUB=expired", session=session)
with pytest.raises(WeiboAuthError, match="重新登录微博"):
client.fetch_home()
def test_fetch_home_reports_non_json_endpoint_path():
session = FakeSession(["<html><body>gateway error</body></html>"])
client = WeiboClient("SUB=test", session=session)
with pytest.raises(WeiboTransportError, match="/aj/mall/home"):
client.fetch_home()
def test_generate_bind_scheme_posts_account_type_without_weibo_cookie():
session = FakeSession(
[