test: fix mypy errors in IE-exclude test
- annotate monkeypatch fixture as pytest.MonkeyPatch - import invest_engine parser module directly instead of via imap_mod.ie_parser (mypy's strict "no implicit re-export" rule trips on the indirection) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
68d4832c2e
commit
fe35c8e826
1 changed files with 7 additions and 3 deletions
|
|
@ -2,8 +2,12 @@ from __future__ import annotations
|
|||
|
||||
from datetime import UTC, date, datetime
|
||||
from decimal import Decimal
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from broker_sync.models import AccountType, Activity, ActivityType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pytest import MonkeyPatch
|
||||
from broker_sync.providers.imap import (
|
||||
_IE_GIA_ACCOUNT_ID,
|
||||
_IE_ISA_ACCOUNT_ID,
|
||||
|
|
@ -101,11 +105,12 @@ def test_non_ie_activities_passed_through_unchanged() -> None:
|
|||
assert routed[0].account_type is AccountType.GIA
|
||||
|
||||
|
||||
def test_exclude_invest_engine_skips_ie_emails(monkeypatch) -> None:
|
||||
def test_exclude_invest_engine_skips_ie_emails(monkeypatch: "MonkeyPatch") -> None:
|
||||
"""BROKER_SYNC_IMAP_EXCLUDE_PROVIDERS=invest-engine should skip IE messages
|
||||
so we don't duplicate IE buys already ingested via the bearer-token API path.
|
||||
Schwab routing must remain unaffected."""
|
||||
from broker_sync.providers import imap as imap_mod
|
||||
from broker_sync.providers.parsers import invest_engine as ie_parser
|
||||
|
||||
ie_email = (
|
||||
b"From: noreply@investengine.com\r\n"
|
||||
|
|
@ -120,8 +125,7 @@ def test_exclude_invest_engine_skips_ie_emails(monkeypatch) -> None:
|
|||
b"<html><body>no-op</body></html>\r\n"
|
||||
)
|
||||
monkeypatch.setattr(imap_mod, "_fetch_all", lambda _: [ie_email, schwab_email])
|
||||
monkeypatch.setattr(imap_mod.ie_parser, "parse_invest_engine_email",
|
||||
lambda raw: [object()])
|
||||
monkeypatch.setattr(ie_parser, "parse_invest_engine_email", lambda raw: [object()])
|
||||
monkeypatch.setattr(imap_mod, "parse_schwab_email", lambda html: [object()])
|
||||
|
||||
creds = imap_mod.ImapCreds(host="h", user="u", password="p", directory="d")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue