"""Settings expose a warehouse_path and ensure_dirs creates its parent."""
from __future__ import annotations

from fxhnt.adapters.warehouse import DuckDbFeatureStore, get_feature_store
from fxhnt.config import Settings


def test_settings_has_warehouse_path_default() -> None:
    s = Settings()
    assert s.warehouse_path.endswith("warehouse.duckdb")


def test_feature_store_default_is_postgres() -> None:
    """SAFETY: postgres is the default feature store so a job that forgets
    FXHNT_FEATURE_STORE can't silently write to a throwaway DuckDB file. The
    live stack is postgres; duckdb is now the explicit opt-in (tests/B3)."""
    assert Settings().feature_store == "postgres"


def test_get_feature_store_duckdb_opt_in_still_works(tmp_path) -> None:
    """The duckdb opt-in still returns the embedded DuckDbFeatureStore."""
    settings = Settings(feature_store="duckdb", warehouse_path=str(tmp_path / "wh.duckdb"))
    store = get_feature_store(settings)
    assert isinstance(store, DuckDbFeatureStore)
    store.close()


def test_ensure_dirs_creates_warehouse_parent(tmp_path) -> None:
    target = tmp_path / "wh" / "warehouse.duckdb"
    s = Settings(warehouse_path=str(target))
    s.ensure_dirs()
    assert target.parent.is_dir()
