feat(V2): migrazione macro completa (read-only, env ignored)
- exchanges/macro: cot.py + cot_contracts.py + fetchers.py copiati 1:1 con rewrite import mcp_common -> cerbero_mcp.common, mcp_macro -> cerbero_mcp.exchanges.macro - nuovo MacroClient stateless wrapper: trasporta solo fred_api_key/finnhub_api_key, niente HTTP session (i fetchers usano async_client ad-hoc) - tools.py: 11 tool (get_treasury_yields, get_yield_curve_slope, get_breakeven_inflation, get_economic_indicators, get_macro_calendar, get_market_overview, get_equity_futures, get_asset_price, get_cot_tff, get_cot_disaggregated, get_cot_extreme_positioning) — niente write, niente leverage_cap - routers/macro.py: prefix /mcp-macro, 11 route POST /tools/* - builder branch macro: stesse credenziali per testnet/mainnet (env ignorato); registry istanzia 2 entry, costo trascurabile (wrapper stateless) - test migrati: test_cot.py + test_fetchers.py (test_server_acl.py skippato V1-only) - nuovo test test_build_client_macro_no_env_distinction in test_exchanges_builder.py Suite: 224 passed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -102,6 +102,29 @@ async def test_build_client_alpaca_returns_correct_env(monkeypatch):
|
||||
assert c_live.paper is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_build_client_macro_no_env_distinction(monkeypatch):
|
||||
from tests.unit.test_settings import _minimal_env
|
||||
|
||||
for k, v in _minimal_env().items():
|
||||
monkeypatch.setenv(k, v)
|
||||
|
||||
from cerbero_mcp.settings import Settings
|
||||
from cerbero_mcp.exchanges import build_client
|
||||
from cerbero_mcp.exchanges.macro.client import MacroClient
|
||||
|
||||
s = Settings()
|
||||
c_test = await build_client(s, "macro", "testnet")
|
||||
c_live = await build_client(s, "macro", "mainnet")
|
||||
|
||||
# entrambi sono MacroClient validi (env ignorato)
|
||||
assert isinstance(c_test, MacroClient)
|
||||
assert isinstance(c_live, MacroClient)
|
||||
# Stesse credenziali (env ignorato)
|
||||
assert c_test.fred_api_key == c_live.fred_api_key
|
||||
assert c_test.finnhub_api_key == c_live.finnhub_api_key
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_build_client_unknown_exchange_raises(monkeypatch):
|
||||
from tests.unit.test_settings import _minimal_env
|
||||
|
||||
Reference in New Issue
Block a user