broker-sync/tests
Viktor Barzin f089b8b93a Add Schwab email parser (port from finance/)
Schwab's workplace-RSU confirmation emails have 5 data td elements
with class='dark-background-body' align='right': date, direction, qty,
ticker, price-with-currency-sign. One email → one Activity.

- parse_schwab_email(raw_html) -> list[Activity] (1-item or empty)
- Empty on any parse failure (IMAP batch shouldn't crash on one bad mail)
- Deterministic external_id ('schwab📅ticker:type:qty') — stable
  across re-pulls so dedup works
- Hardcoded to account 'schwab-workplace' / AccountType.GIA / USD
- 6 unit tests: SELL + BUY happy path, malformed, missing cells,
  external-id stability, commas in price

Dropped from the original finance port:
- msg_timestamp-based external id (non-deterministic — would re-import
  on every IMAP walk). Replaced with a hash-stable key.
- Currency.from_sign() currency hack. Schwab US is USD-only; we'll add
  FX when that changes.

poetry run pytest -q   →  109 passed, 1 skipped
poetry run mypy        →  clean (added types-python-dateutil)
poetry run ruff check  →  clean
2026-04-17 22:08:40 +00:00
..
fixtures Pin InvestEngine parser failure modes — empty-on-junk + partial-match 2026-04-17 22:02:48 +00:00
providers Add Schwab email parser (port from finance/) 2026-04-17 22:08:40 +00:00
sinks sinks: feed /import/check enrichment into /import body 2026-04-17 20:54:17 +00:00
__init__.py Initial scaffold + canonical Activity model 2026-04-17 19:16:11 +00:00
test_cli.py Add broker-sync invest-engine CLI subcommand 2026-04-17 21:59:31 +00:00
test_dedup.py Add SyncRecordStore for authoritative dedup 2026-04-17 19:17:12 +00:00
test_fx.py Add FxCache and convert_to_gbp core 2026-04-17 19:18:41 +00:00
test_fx_ecb.py Add ECB FX fetcher + cache population 2026-04-17 19:32:23 +00:00
test_models.py Initial scaffold + canonical Activity model 2026-04-17 19:16:11 +00:00
test_normaliser.py Add Provider protocol and normaliser 2026-04-17 19:20:12 +00:00
test_pipeline.py sinks: feed /import/check enrichment into /import body 2026-04-17 20:54:17 +00:00