mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-11-20 08:09:56 +02:00
fix(router): report a vendor chain with an unavailable vendor as unavailable, not as no data
- a vendor that throttled or failed the request never said whether it has the symbol, so another vendor's "no data" no longer speaks for the chain
This commit is contained in:
@@ -94,6 +94,26 @@ class RouterHandlesBaseTypesTests(unittest.TestCase):
|
||||
), self.assertRaises(AlphaVantageNotConfiguredError):
|
||||
router.route_to_vendor("get_stock_data", "AAPL", "2026-01-01", "2026-01-10")
|
||||
|
||||
def test_an_unavailable_vendor_keeps_absence_from_being_claimed(self):
|
||||
# The throttled vendor's coverage was never learned, so "no usable data
|
||||
# from any configured vendor" would be a claim nobody checked.
|
||||
def throttled(*a, **k):
|
||||
raise VendorUnavailableError("Yahoo HTTP 429")
|
||||
|
||||
def timed_out(*a, **k):
|
||||
raise TimeoutError("read timed out") # a vendor that does not type its failures
|
||||
|
||||
def not_covered(*a, **k):
|
||||
raise NoMarketDataError("AAPL", "AAPL", "not covered")
|
||||
|
||||
for chain in ({"yfinance": throttled, "alpha_vantage": not_covered},
|
||||
{"yfinance": not_covered, "alpha_vantage": throttled},
|
||||
{"alpha_vantage": timed_out, "yfinance": not_covered}):
|
||||
set_config({"data_vendors": {"core_stock_apis": ",".join(chain)}})
|
||||
with mock.patch.dict(router.VENDOR_METHODS, {"get_stock_data": chain}, clear=False):
|
||||
out = router.route_to_vendor("get_stock_data", "AAPL", "2026-01-01", "2026-01-10")
|
||||
self.assertTrue(out.startswith("DATA_UNAVAILABLE"), out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user