comdirect ingest tests (tbc)
This commit is contained in:
@@ -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,9 +139,8 @@ 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)
|
||||
db_load_function(session, row, account)
|
||||
session.commit()
|
||||
for row in data:
|
||||
data_validated = account.model.model_validate(row)
|
||||
assert isinstance(data_validated, account.model)
|
||||
db_load_function(session, row, account)
|
||||
session.commit()
|
||||
|
||||
Reference in New Issue
Block a user