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\""]))