mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-11-28 03:56:26 +02:00
fix(alpha_vantage): keep the API key out of every error an Alpha Vantage answer raises
- rate-limit and invalid-key notices are scrubbed of the key as the rejection message is
This commit is contained in:
@@ -86,6 +86,23 @@ def test_a_rejected_request_is_unavailable_not_data(monkeypatch):
|
||||
assert out.startswith("DATA_UNAVAILABLE"), out
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.parametrize("body", [
|
||||
'{"Note": "Thank you for using key k-secret. API call frequency is 5 calls per minute."}',
|
||||
'{"Information": "the apikey k-secret is invalid or missing."}',
|
||||
])
|
||||
def test_the_key_never_reaches_an_error_message(monkeypatch, body):
|
||||
"""Alpha Vantage can echo the key in its notices; error text reaches logs and reports."""
|
||||
from tradingagents.dataflows.errors import VendorError
|
||||
|
||||
monkeypatch.setenv("ALPHA_VANTAGE_API_KEY", "k-secret")
|
||||
monkeypatch.setattr(net.requests, "get", _patched_get(body))
|
||||
|
||||
with pytest.raises(VendorError) as raised:
|
||||
av._make_api_request("TIME_SERIES_DAILY", {"symbol": "AAPL"})
|
||||
assert "k-secret" not in str(raised.value)
|
||||
|
||||
|
||||
_FUNDAMENTALS_JSON = json.dumps({
|
||||
"symbol": "AAPL",
|
||||
"annualReports": [
|
||||
|
||||
Reference in New Issue
Block a user