from __future__ import annotations import pytest from broker_sync.models import Account, AccountType from broker_sync.providers.fidelity_planviewer import ( ACCOUNT_ID, FidelityCreds, FidelityPlanViewerProvider, FidelityProviderConfigError, ) def test_accounts_exposes_single_workplace_pension_account() -> None: prov = FidelityPlanViewerProvider(FidelityCreds( storage_state_path="/tmp/x", plan_id="ABC123", )) accounts = prov.accounts() assert accounts == [ Account( id=ACCOUNT_ID, name="Fidelity UK Pension", account_type=AccountType.WORKPLACE_PENSION, currency="GBP", provider="fidelity-planviewer", ), ] async def test_fetch_raises_until_endpoints_captured() -> None: """Until Viktor pastes the transactions/holdings cURLs, fetch() must fail loudly rather than silently importing nothing. Swap this test for real parser tests once the API shapes are known and `FidelityPlanViewerProvider.fetch` is wired up against fixtures. """ prov = FidelityPlanViewerProvider(FidelityCreds( storage_state_path="/tmp/x", plan_id="ABC123", )) with pytest.raises(FidelityProviderConfigError, match="endpoint paths"): async for _ in prov.fetch(): pytest.fail("fetch should not yield before endpoints are configured")