fix: 对齐 test_account 在 404 响应下的日志成功标志及错误类型口径,与标准接口行为一致

This commit is contained in:
liumangmang
2026-07-02 00:28:34 +08:00
parent 3b23f21ef3
commit 9c9a4b3423
2 changed files with 5 additions and 1 deletions
+2
View File
@@ -380,6 +380,8 @@ class Sub2ApiWebsiteClient:
with self._client.stream("POST", url, headers=headers) as response: with self._client.stream("POST", url, headers=headers) as response:
status_code = response.status_code status_code = response.status_code
if response.status_code == 404: if response.status_code == 404:
error_type = "HTTPStatus"
error_msg = "HTTP 404"
return {"status": "404", "cleanup_allowed": True, "message": "账号在远端不存在 (404)"} return {"status": "404", "cleanup_allowed": True, "message": "账号在远端不存在 (404)"}
if response.status_code >= 400: if response.status_code >= 400:
response.raise_for_status() response.raise_for_status()
+3 -1
View File
@@ -95,7 +95,9 @@ def test_website_client_test_account_sse_scenarios(monkeypatch):
assert res["cleanup_allowed"] is True assert res["cleanup_allowed"] is True
assert len(log_calls) == 3 assert len(log_calls) == 3
assert log_calls[-1]["status_code"] == 404 assert log_calls[-1]["status_code"] == 404
assert log_calls[-1]["success"] is True assert log_calls[-1]["success"] is False
assert log_calls[-1]["error_type"] == "HTTPStatus"
assert log_calls[-1]["error_message"] == "HTTP 404"
# 4. error event # 4. error event
monkeypatch.setattr(c._client, "stream", mock_stream(200, ["event: error", "data: \"internal error\""])) monkeypatch.setattr(c._client, "stream", mock_stream(200, ["event: error", "data: \"internal error\""]))