30 lines
975 B
Python
30 lines
975 B
Python
"""`fxhnt fetch` wiring: futures-only since Phase 0b Task 7e retired the crypto_pit leg (fetcher
|
|
monkeypatched — no network)."""
|
|
from __future__ import annotations
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from fxhnt import cli
|
|
|
|
runner = CliRunner()
|
|
|
|
|
|
def test_fetch_invokes_futures(monkeypatch, tmp_path) -> None:
|
|
calls = {}
|
|
|
|
def _fake_futures(data_dir, **kw):
|
|
calls["futures"] = data_dir
|
|
return (10, 1, 0.3)
|
|
|
|
monkeypatch.setattr(cli, "fetch_futures", _fake_futures)
|
|
monkeypatch.setenv("DATABENTO_API_KEY", "test-key")
|
|
res = runner.invoke(cli.app, ["fetch", "--data-dir", str(tmp_path)])
|
|
assert res.exit_code == 0 and calls.get("futures") == str(tmp_path)
|
|
|
|
|
|
def test_fetch_without_key_exits_clean(monkeypatch, tmp_path) -> None:
|
|
monkeypatch.delenv("DATABENTO_API_KEY", raising=False)
|
|
res = runner.invoke(cli.app, ["fetch", "--data-dir", str(tmp_path)])
|
|
assert res.exit_code == 1
|
|
assert "DATABENTO_API_KEY" in res.output
|