From 9c9a4b3423087544def5b25166878a77c960f1df Mon Sep 17 00:00:00 2001 From: liumangmang Date: Thu, 2 Jul 2026 00:28:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=B9=E9=BD=90=20test=5Faccount=20?= =?UTF-8?q?=E5=9C=A8=20404=20=E5=93=8D=E5=BA=94=E4=B8=8B=E7=9A=84=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=88=90=E5=8A=9F=E6=A0=87=E5=BF=97=E5=8F=8A=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=B1=BB=E5=9E=8B=E5=8F=A3=E5=BE=84=EF=BC=8C=E4=B8=8E?= =?UTF-8?q?=E6=A0=87=E5=87=86=E6=8E=A5=E5=8F=A3=E8=A1=8C=E4=B8=BA=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/services/website_client.py | 2 ++ backend/test_cleanup_invalid_accounts.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/services/website_client.py b/backend/app/services/website_client.py index 6cf1e26..396fefa 100644 --- a/backend/app/services/website_client.py +++ b/backend/app/services/website_client.py @@ -380,6 +380,8 @@ class Sub2ApiWebsiteClient: with self._client.stream("POST", url, headers=headers) as response: status_code = response.status_code if response.status_code == 404: + error_type = "HTTPStatus" + error_msg = "HTTP 404" return {"status": "404", "cleanup_allowed": True, "message": "账号在远端不存在 (404)"} if response.status_code >= 400: response.raise_for_status() diff --git a/backend/test_cleanup_invalid_accounts.py b/backend/test_cleanup_invalid_accounts.py index c13d4b9..531a224 100644 --- a/backend/test_cleanup_invalid_accounts.py +++ b/backend/test_cleanup_invalid_accounts.py @@ -95,7 +95,9 @@ def test_website_client_test_account_sse_scenarios(monkeypatch): assert res["cleanup_allowed"] is True assert len(log_calls) == 3 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 monkeypatch.setattr(c._client, "stream", mock_stream(200, ["event: error", "data: \"internal error\""]))