comdirect stringification
This commit is contained in:
+17
-5
@@ -1,4 +1,3 @@
|
||||
from collections.abc import Callable
|
||||
from decimal import Decimal
|
||||
from typing import Any
|
||||
|
||||
@@ -27,6 +26,18 @@ def _amount() -> Decimal:
|
||||
)
|
||||
|
||||
|
||||
def _amount_eur() -> str:
|
||||
"""Generate German-formatted decimal string (e.g., '32,43')."""
|
||||
val = B4wExportFactory.__faker__.pydecimal(
|
||||
left_digits=6,
|
||||
right_digits=2,
|
||||
positive=True,
|
||||
min_value=Decimal("0.01"),
|
||||
)
|
||||
# Format as German string with comma decimal separator
|
||||
return f"{val:.2f}".replace(".", ",").strip()
|
||||
|
||||
|
||||
def _sentence() -> str:
|
||||
return B4wExportFactory.__faker__.sentence(
|
||||
nb_words=8,
|
||||
@@ -61,16 +72,17 @@ class B4wExportFactory(ModelFactory[B4wExport]):
|
||||
|
||||
class ComdirectGiroFactory(ModelFactory[ComdirectGiro]):
|
||||
__faker__ = Faker("de_DE")
|
||||
__use_example__ = True
|
||||
__use_examples__ = True
|
||||
|
||||
Buchungstext = Use(_sentence)
|
||||
text = Use(_sentence)
|
||||
amount_eur = Use(_amount_eur)
|
||||
|
||||
|
||||
class ComdirectCreditCardFactory(ModelFactory[ComdirectCreditCard]):
|
||||
__faker__ = Faker("de_DE")
|
||||
__use_example__ = True
|
||||
__use_examples__ = True
|
||||
|
||||
|
||||
class ComdirectDepotFactory(ModelFactory[ComdirectDepot]):
|
||||
__faker__ = Faker("de_DE")
|
||||
__use_example__ = True
|
||||
__use_examples__ = True
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
from src.models.comdirect import ComdirectGiro
|
||||
from tests.factories import ComdirectGiroFactory
|
||||
|
||||
|
||||
def test_comdirect_giro_basic_and_stringification():
|
||||
data = ComdirectGiroFactory.build()
|
||||
assert data
|
||||
assert isinstance(data, ComdirectGiro)
|
||||
orig_headers = data.get_orig_headers()
|
||||
assert orig_headers
|
||||
assert isinstance(orig_headers, str)
|
||||
header_list = orig_headers.split(";")
|
||||
assert len(header_list) > 0
|
||||
assert set(header_list) == {
|
||||
'"Wertstellung (Valuta)"',
|
||||
'"Umsatz in EUR"',
|
||||
'"Buchungstag"',
|
||||
'"Vorgang"',
|
||||
'"Buchungstext"',
|
||||
}
|
||||
orig_row = data.get_orig_row()
|
||||
assert orig_row
|
||||
assert isinstance(orig_row, str)
|
||||
assert len(orig_row.split(";")) > 0
|
||||
Reference in New Issue
Block a user