test_metals.py 870 B

1234567891011121314151617181920212223242526
  1. from src.metals_mcp.mcp_tools import client, get_capabilities, get_candles, get_last_candle, get_price
  2. def test_capabilities():
  3. caps = get_capabilities()
  4. assert caps["server"] == "metals-mcp"
  5. def test_scaffold_tools():
  6. assert get_price("XAU/USD")["symbol"] == "XAU/USD"
  7. assert get_candles("XAU/USD")["candles"] == []
  8. assert get_last_candle("XAU/USD")["candle"] is None
  9. def test_price_supports_counter_currency(monkeypatch):
  10. monkeypatch.setattr(client, "pair_is_supported", lambda symbol, counter_currency=None: True)
  11. class DummyQuote:
  12. mid = 4049.0
  13. timestamp = 1234567890
  14. monkeypatch.setattr(client, "fetch_quote", lambda pair: DummyQuote())
  15. quote = get_price("XAU", counter_currency="EUR")
  16. assert quote["pair"] == "XAU/EUR"
  17. assert quote["counter_currency"] == "EUR"
  18. assert quote["price"] == 4049.0