Files
fxhnt/tests/integration/test_fetch_cli.py
jgrusewski fa10f92d7e feat(fetch): fxhnt fetch CLI (crypto/futures into data-dir)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 12:24:51 +02:00

40 lines
1.3 KiB
Python

"""`fxhnt fetch` wiring: runs the selected fetchers into the data dir (fetchers monkeypatched — no network)."""
from __future__ import annotations
from typer.testing import CliRunner
from fxhnt import cli
runner = CliRunner()
def test_fetch_crypto_only_invokes_crypto(monkeypatch, tmp_path) -> None:
calls = {}
def _fake_crypto(data_dir, **kw):
calls["crypto"] = data_dir
return (5, 5)
def _fake_futures(data_dir, **kw):
calls["futures"] = data_dir
return (0, 0, 0.0)
monkeypatch.setattr(cli, "fetch_crypto_pit", _fake_crypto)
monkeypatch.setattr(cli, "fetch_futures", _fake_futures)
res = runner.invoke(cli.app, ["fetch", "--data-dir", str(tmp_path), "--crypto", "--no-futures"])
assert res.exit_code == 0
assert calls.get("crypto") == str(tmp_path) and "futures" not in calls
def test_fetch_futures_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_crypto_pit", lambda data_dir, **kw: (0, 0))
monkeypatch.setattr(cli, "fetch_futures", _fake_futures)
res = runner.invoke(cli.app, ["fetch", "--data-dir", str(tmp_path), "--no-crypto", "--futures"])
assert res.exit_code == 0 and calls.get("futures") == str(tmp_path)