fix(huya): 一键查询统一最新 CK 探针与 HTTP 快速通道
This commit is contained in:
@@ -230,9 +230,7 @@ def _runner(monkeypatch, shop_client, activity_client=None):
|
||||
runner = HuyaBatchRunner(db=None, batch_id="test-batch", task_type="query_all")
|
||||
marks: list[tuple[str, str, dict | None]] = []
|
||||
logs: list[tuple[str, str]] = []
|
||||
monkeypatch.setattr(
|
||||
runner, "_shop_client", lambda uid, cookie: shop_client, raising=False
|
||||
)
|
||||
monkeypatch.setattr(runner, "_http_client", lambda: shop_client, raising=False)
|
||||
if activity_client is not None:
|
||||
monkeypatch.setattr(
|
||||
runner,
|
||||
@@ -324,7 +322,10 @@ def test_query_all_fills_expire_time_from_season(monkeypatch):
|
||||
)
|
||||
runner, marks, _logs = _runner(monkeypatch, shop_client, activity_client=object())
|
||||
monkeypatch.setattr(
|
||||
runner, "_resolve_bind_status", lambda **kwargs: (None, {}), raising=False
|
||||
runner,
|
||||
"_probe_bind_status",
|
||||
lambda **kwargs: (_FakeBindStatus(status=601, msg="活动已下线"), {}),
|
||||
raising=False,
|
||||
)
|
||||
account = HuyaAccount(uid=str(UID), cookie=COOKIE)
|
||||
|
||||
@@ -606,7 +607,7 @@ def test_query_all_combines_points_elite_and_role(monkeypatch):
|
||||
runner, marks, _logs = _runner(monkeypatch, shop_client, activity_client=object())
|
||||
monkeypatch.setattr(
|
||||
runner,
|
||||
"_resolve_bind_status",
|
||||
"_probe_bind_status",
|
||||
lambda **kwargs: (_FakeBindStatus(), {"bind_status_source": "outer"}),
|
||||
raising=False,
|
||||
)
|
||||
@@ -660,7 +661,10 @@ def test_query_all_reports_not_opened_without_order_lookup(monkeypatch):
|
||||
shop_client = _StubClient(redeem=_redeem(REDEEM_NOT_OPENED_HEX))
|
||||
runner, marks, _logs = _runner(monkeypatch, shop_client, activity_client=object())
|
||||
monkeypatch.setattr(
|
||||
runner, "_resolve_bind_status", lambda **kwargs: (None, {}), raising=False
|
||||
runner,
|
||||
"_probe_bind_status",
|
||||
lambda **kwargs: (_FakeBindStatus(status=601, msg="活动已下线"), {}),
|
||||
raising=False,
|
||||
)
|
||||
account = HuyaAccount(uid=str(UID), cookie=COOKIE)
|
||||
|
||||
@@ -669,13 +673,13 @@ def test_query_all_reports_not_opened_without_order_lookup(monkeypatch):
|
||||
)
|
||||
|
||||
status, message, result = marks[-1]
|
||||
# 角色接口挂了不影响宝典/积分结论
|
||||
# 角色接口业务失败不影响宝典/积分结论
|
||||
assert status == "success"
|
||||
assert result["elite_opened"] is False
|
||||
assert account.elite_opened is False
|
||||
assert account.elite_open_time is None
|
||||
assert "未开通宝典" in message
|
||||
assert "角色信息接口无响应" in message
|
||||
assert "活动已下线" in message
|
||||
# 未开通不查订单(省一次请求)
|
||||
assert [name for name, _kwargs in shop_client.calls] == ["get_redeem_need_goods"]
|
||||
|
||||
@@ -684,9 +688,12 @@ def test_query_all_fails_when_points_center_unreachable(monkeypatch):
|
||||
shop_client = _StubClient(redeem=None)
|
||||
runner, marks, _logs = _runner(monkeypatch, shop_client, activity_client=object())
|
||||
monkeypatch.setattr(
|
||||
runner, "_resolve_bind_status", lambda **kwargs: (None, {}), raising=False
|
||||
runner,
|
||||
"_probe_bind_status",
|
||||
lambda **kwargs: (_FakeBindStatus(status=601, msg="活动已下线"), {}),
|
||||
raising=False,
|
||||
)
|
||||
account = HuyaAccount(uid=str(UID), cookie=COOKIE)
|
||||
account = HuyaAccount(uid=str(UID), cookie=COOKIE, status="imported")
|
||||
|
||||
runner._execute_query_all(
|
||||
None, None, account, {"uid": UID, "cookie": COOKIE}, {"bind_act_id": "9271"}
|
||||
@@ -695,9 +702,9 @@ def test_query_all_fails_when_points_center_unreachable(monkeypatch):
|
||||
status, message, result = marks[-1]
|
||||
assert status == "failed"
|
||||
assert "积分中心接口无响应" in message
|
||||
# 两条通道都没回包:CK 失效标记跟着失败结果一起落库(前端整行标红)
|
||||
assert result["ck_expired"] is True
|
||||
assert account.status == "ck_expired"
|
||||
assert result.get("ck_expired") is None
|
||||
# 没有查到任何东西时不能把账号标成 all_queried
|
||||
assert account.status == "imported"
|
||||
|
||||
|
||||
def test_query_all_flags_ck_expired_when_role_lookup_has_no_response(monkeypatch):
|
||||
@@ -705,13 +712,16 @@ def test_query_all_flags_ck_expired_when_role_lookup_has_no_response(monkeypatch
|
||||
|
||||
真机日志(logs/app-2026-10-15.log,hy_297838517)里
|
||||
``webActUI.checkUserBindGameAccount`` 的响应只有 ``newdata keys: ['']``(没有 tRsp),
|
||||
``_resolve_bind_status`` 因此返回 None;积分中心走另一条通道却还能返回 200,
|
||||
``_probe_bind_status`` 因此返回 None;积分中心走另一条通道却还能返回 200,
|
||||
所以不能凭「积分查到了」就当成功,必须打 ck_expired 让页面标红。
|
||||
|
||||
2026-10-17 起一键查询也改成先验 CK:判定失效后立即停止,
|
||||
不再白跑积分中心和宝典接口。
|
||||
"""
|
||||
shop_client = _StubClient(redeem=_redeem(REDEEM_NOT_OPENED_HEX))
|
||||
runner, marks, _logs = _runner(monkeypatch, shop_client, activity_client=object())
|
||||
monkeypatch.setattr(
|
||||
runner, "_resolve_bind_status", lambda **kwargs: (None, {}), raising=False
|
||||
runner, "_probe_bind_status", lambda **kwargs: (None, {}), raising=False
|
||||
)
|
||||
account = HuyaAccount(uid=str(UID), cookie=COOKIE)
|
||||
|
||||
@@ -720,13 +730,12 @@ def test_query_all_flags_ck_expired_when_role_lookup_has_no_response(monkeypatch
|
||||
)
|
||||
|
||||
status, message, result = marks[-1]
|
||||
# 宝典/积分查到了,任务本身不算失败(结果照样展示),但 CK 失效标记必须带上
|
||||
assert status == "success"
|
||||
assert status == "error"
|
||||
assert result["ck_expired"] is True
|
||||
assert result["ck_expired_reason"] == "角色信息接口无响应"
|
||||
assert account.status == "ck_expired"
|
||||
assert "角色信息接口无响应" in message
|
||||
assert "疑似 CK 已失效" in message
|
||||
assert "CK 已失效" in message
|
||||
assert shop_client.calls == []
|
||||
|
||||
|
||||
def test_query_all_keeps_business_error_out_of_ck_expired(monkeypatch):
|
||||
@@ -735,7 +744,7 @@ def test_query_all_keeps_business_error_out_of_ck_expired(monkeypatch):
|
||||
runner, marks, _logs = _runner(monkeypatch, shop_client, activity_client=object())
|
||||
monkeypatch.setattr(
|
||||
runner,
|
||||
"_resolve_bind_status",
|
||||
"_probe_bind_status",
|
||||
lambda **kwargs: (_FakeBindStatus(status=601, msg="活动已下线"), {}),
|
||||
raising=False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user