import datetime as dt

from fxhnt.adapters.persistence.forward_nav import ForwardNavRepo
from fxhnt.application.forward_engine import run_track


class _RecomputeStrat:
    def advance(self, last_date, extra):
        return [("2026-07-07", 0.01), ("2026-07-08", 0.02)], extra


def test_engine_writes_nav_for_a_recompute_track(tmp_path, monkeypatch):
    repo = ForwardNavRepo(f"sqlite:///{tmp_path}/pt.db")
    repo.migrate()
    from fxhnt import registry
    monkeypatch.setitem(registry.STRATEGY_REGISTRY, "sixtyforty",
                        dict(registry.STRATEGY_REGISTRY["sixtyforty"],
                             definition={"params": {"v": 1}, "version": 1, "record_mode": "recompute"}))
    out = run_track(repo, "sixtyforty", _RecomputeStrat(), today="2026-07-06",
                    at=dt.datetime(2026, 7, 8, 23, 30))
    assert out["days"] == 2
    assert [r.date for r in repo.nav_history("sixtyforty")] == ["2026-07-07", "2026-07-08"]
