fix(data): respect the configured vendor chain and log vendor failures

The router silently extended every request to all available vendors regardless
of config, so an explicit single-vendor choice still fell back to others and
returned data from an unexpected source (#988, #289), and serious primary-vendor
errors were swallowed without a trace (#989). The configured vendor list is now
the exact chain (list several for ordered fallback; "default" uses all), unknown
vendors raise, and swallowed vendor errors are logged. Adds an autouse config
isolation fixture so vendor config can't leak between tests.
This commit is contained in:
Yijia-Xiao
2026-06-13 21:11:25 +00:00
parent 76add9048f
commit 65608831f8
4 changed files with 159 additions and 16 deletions

View File

@@ -35,6 +35,25 @@ def _dummy_api_keys(monkeypatch):
monkeypatch.setenv(env_var, os.environ.get(env_var, "placeholder"))
@pytest.fixture(autouse=True)
def _isolate_config():
"""Reset the global dataflows config before and after each test.
``set_config`` merges (it never clears keys absent from the override), so a
test that sets e.g. ``tool_vendors`` would otherwise leak into later tests
and make routing behavior order-dependent. Replace the global outright so
every test starts from a clean DEFAULT_CONFIG.
"""
import copy
import tradingagents.dataflows.config as config_module
import tradingagents.default_config as default_config
config_module._config = copy.deepcopy(default_config.DEFAULT_CONFIG)
yield
config_module._config = copy.deepcopy(default_config.DEFAULT_CONFIG)
@pytest.fixture()
def mock_llm_client():
client = MagicMock()