test: 记录双平台小规模真实验收

This commit is contained in:
meijiali
2026-07-03 14:53:54 +08:00
parent eedb1db4da
commit 46037a217b
3 changed files with 78 additions and 1 deletions
+3 -1
View File
@@ -38,7 +38,8 @@ def test_tikhub_client_retries_429_with_exponential_backoff(monkeypatch):
def test_tikhub_client_raises_structured_error_after_retries(monkeypatch):
monkeypatch.setattr("app.platforms.base.time.sleep", lambda _seconds: None)
sleeps = []
monkeypatch.setattr("app.platforms.base.time.sleep", sleeps.append)
transport = SequenceTransport([httpx.Response(429, json={"message": "Too Many Requests"}) for _ in range(4)])
http_client = httpx.Client(transport=httpx.MockTransport(transport))
client = TikHubClient(base_url="https://api.test", api_key="secret-token", http_client=http_client)
@@ -49,3 +50,4 @@ def test_tikhub_client_raises_structured_error_after_retries(monkeypatch):
assert exc_info.value.error_type == "rate_limited"
assert exc_info.value.status_code == 429
assert "secret-token" not in str(exc_info.value)
assert sleeps == [1, 2, 4]