fix(workspaces): seed new defaults from live quote
This commit is contained in:
@@ -75,10 +75,24 @@ def test_root_without_workspace_cookie_shows_welcome_page(tmp_path, monkeypatch)
|
||||
def test_bootstrap_endpoint_requires_turnstile_and_creates_workspace_cookie_and_redirects(
|
||||
tmp_path, monkeypatch
|
||||
) -> None:
|
||||
from app import main as main_module
|
||||
from app.services import turnstile as turnstile_module
|
||||
|
||||
class _QuoteDataService:
|
||||
default_symbol = "GLD"
|
||||
|
||||
async def get_quote(self, symbol: str) -> dict[str, object]:
|
||||
return {
|
||||
"symbol": symbol,
|
||||
"price": 404.19,
|
||||
"quote_unit": "share",
|
||||
"source": "test",
|
||||
"updated_at": "2026-03-25T00:00:00+00:00",
|
||||
}
|
||||
|
||||
repo = _install_workspace_repo(tmp_path, monkeypatch)
|
||||
monkeypatch.setattr(turnstile_module, "verify_turnstile_token", lambda *args, **kwargs: True)
|
||||
monkeypatch.setattr(main_module, "get_data_service", lambda: _QuoteDataService())
|
||||
|
||||
with TestClient(app) as client:
|
||||
response = client.post(
|
||||
@@ -94,6 +108,11 @@ def test_bootstrap_endpoint_requires_turnstile_and_creates_workspace_cookie_and_
|
||||
assert repo.workspace_exists(workspace_id)
|
||||
assert response.cookies.get("workspace_id") == workspace_id
|
||||
|
||||
created = repo.load_portfolio_config(workspace_id)
|
||||
assert created.entry_price == 4041.9
|
||||
assert created.gold_ounces == 100.0
|
||||
assert created.gold_value == 404190.0
|
||||
|
||||
|
||||
def test_root_with_valid_workspace_cookie_redirects_to_workspace(tmp_path, monkeypatch) -> None:
|
||||
repo = _install_workspace_repo(tmp_path, monkeypatch)
|
||||
|
||||
Reference in New Issue
Block a user