fix(portfolio): default new workspaces to 100 oz
This commit is contained in:
@@ -156,6 +156,47 @@ def test_portfolio_repository_rejects_unsupported_schema_version(tmp_path) -> No
|
||||
PortfolioRepository(config_path=config_path).load()
|
||||
|
||||
|
||||
def test_portfolio_config_defaults_to_100_ounces() -> None:
|
||||
config = PortfolioConfig()
|
||||
|
||||
assert config.gold_value == pytest.approx(215_000.0, rel=1e-12)
|
||||
assert config.entry_price == pytest.approx(2_150.0, rel=1e-12)
|
||||
assert config.gold_ounces == pytest.approx(100.0, rel=1e-12)
|
||||
|
||||
|
||||
def test_portfolio_repository_upgrades_legacy_default_workspace_footprint(tmp_path) -> None:
|
||||
config_path = tmp_path / "portfolio_config.json"
|
||||
config_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"schema_version": 2,
|
||||
"portfolio": {
|
||||
"gold_value": {"value": "215000.0", "currency": "USD"},
|
||||
"entry_price": {"value": "215.0", "currency": "USD", "per_weight_unit": "ozt"},
|
||||
"gold_ounces": {"value": "1000.0", "unit": "ozt"},
|
||||
"entry_basis_mode": "value_price",
|
||||
"loan_amount": {"value": "145000.0", "currency": "USD"},
|
||||
"margin_threshold": {"value": "0.75", "unit": "ratio"},
|
||||
"monthly_budget": {"value": "8000.0", "currency": "USD"},
|
||||
"ltv_warning": {"value": "0.70", "unit": "ratio"},
|
||||
"primary_source": "yfinance",
|
||||
"fallback_source": "yfinance",
|
||||
"refresh_interval": {"value": 5, "unit": "seconds"},
|
||||
"volatility_spike": {"value": "0.25", "unit": "ratio"},
|
||||
"spot_drawdown": {"value": "7.5", "unit": "percent"},
|
||||
"email_alerts": False,
|
||||
},
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
config = PortfolioRepository(config_path=config_path).load()
|
||||
|
||||
assert config.gold_value == pytest.approx(215_000.0, rel=1e-12)
|
||||
assert config.entry_price == pytest.approx(2_150.0, rel=1e-12)
|
||||
assert config.gold_ounces == pytest.approx(100.0, rel=1e-12)
|
||||
|
||||
|
||||
def test_portfolio_repository_rejects_non_integer_refresh_interval_value(tmp_path) -> None:
|
||||
repo = PortfolioRepository(config_path=tmp_path / "portfolio_config.json")
|
||||
config = PortfolioConfig()
|
||||
|
||||
Reference in New Issue
Block a user