Ingest comdirect #5

Merged
mathias2784 merged 31 commits from ingest-comdirect into master 2026-09-13 20:27:16 +00:00
2 changed files with 41 additions and 8 deletions
Showing only changes of commit 75a787aece - Show all commits
+3 -3
View File
@@ -44,6 +44,7 @@ def reader_comdirect(path: Path) -> dict[str, list[ComdirectExportModel]]:
result = {}
raw = _reader_raw_comdirect(path)
for account in ACCOUNTS:
assert account.name in raw
data_raw: Csv2Dict = raw.pop(account.name)
data: list = list(map(account.model.model_validate, data_raw))
result[account.name] = data
@@ -53,7 +54,7 @@ def reader_comdirect(path: Path) -> dict[str, list[ComdirectExportModel]]:
def _reader_raw_comdirect(path: Path) -> CsV2DictMulti:
with path.open(encoding="latin1") as fid:
with path.open("r", encoding="utf-8") as fid:
lines = fid.readlines()
expect_next = EXPECT_LINE.ACCOUNT_NAME
@@ -122,7 +123,7 @@ def upsert_comdirect_giro(
)
def ingest_comdirect(path: Path, account_iban: str, account_currency: str):
def ingest_comdirect(session: Session, path: Path, account_iban: str, account_currency: str):
assert SOURCE_COMDIRECT
data_collection = reader_comdirect(path)
for account_name, data in data_collection.items():
@@ -138,7 +139,6 @@ def ingest_comdirect(path: Path, account_iban: str, account_currency: str):
)
else:
continue
with get_session() as session:
for row in data:
data_validated = account.model.model_validate(row)
assert isinstance(data_validated, account.model)
+33
View File
@@ -0,0 +1,33 @@
from pathlib import Path
import pytest
from faker import Faker
from sqlalchemy.orm import Session
from src.constants import Currency
from src.ingest.comdirect import (
_reader_raw_comdirect,
ingest_comdirect,
reader_comdirect,
)
TEST_DATA_PATH = Path("tests/test_data/comdirect_export_dummy_01.txt")
def test_reader_comdirect_raw():
result = _reader_raw_comdirect(TEST_DATA_PATH)
assert result
def test_reader_comdirect():
result = reader_comdirect(TEST_DATA_PATH)
assert result
assert isinstance(result, dict)
@pytest.mark.skip
def test_ingest_comdirect(db_session: Session):
ingest_comdirect(
session=db_session,
path=TEST_DATA_PATH,
account_iban=Faker().iban(),
account_currency=Currency.EUR,
)