Compare commits

...
2 Commits
Author SHA1 Message Date
mathias2784 a482f38cb6 black
Tests / test (push) Failing after 7s
2026-09-13 22:06:28 +02:00
mathias2784 551d8ffbde flexible encoding when reading comdirect data 2026-09-13 22:06:20 +02:00
2 changed files with 15 additions and 4 deletions
+13 -4
View File
@@ -5,7 +5,6 @@ from pathlib import Path
from sqlalchemy.orm import Session
from settings import BANK_ACCOUNTS
from src.db import get_session
from src.ingest._common import _upsert
from src.models._common import Csv2Dict, CsV2DictMulti
from src.models.comdirect import (
@@ -52,10 +51,18 @@ def reader_comdirect(path: Path) -> dict[str, list[ComdirectExportModel]]:
return result
def _open_and_readlines(path: Path, encoding: str) -> list:
with path.open("r", encoding=encoding) as fid:
lines = fid.readlines()
return lines
def _reader_raw_comdirect(path: Path) -> CsV2DictMulti:
with path.open("r", encoding="utf-8") as fid:
lines = fid.readlines()
try:
lines = _open_and_readlines(path, encoding="utf-8")
except UnicodeDecodeError:
lines = _open_and_readlines(path, encoding="latin-1")
expect_next = EXPECT_LINE.ACCOUNT_NAME
account_name = None
@@ -123,7 +130,9 @@ def upsert_comdirect_giro(
)
def ingest_comdirect(session: Session, 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():
+2
View File
@@ -18,11 +18,13 @@ 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(