fix(weibo): 识别支付域登录失效
This commit is contained in:
@@ -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(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user