Ingest comdirect #5
+11
-5
@@ -1,4 +1,6 @@
|
|||||||
|
from collections.abc import Callable
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from faker import Faker
|
from faker import Faker
|
||||||
from polyfactory.factories.pydantic_factory import ModelFactory
|
from polyfactory.factories.pydantic_factory import ModelFactory
|
||||||
@@ -10,6 +12,12 @@ from src.models.comdirect import ComdirectCreditCard, ComdirectDepot, ComdirectG
|
|||||||
DEFAULT_CATEGORY = "root_category:parent_category:leaf_category"
|
DEFAULT_CATEGORY = "root_category:parent_category:leaf_category"
|
||||||
|
|
||||||
|
|
||||||
|
def _faker_or_none(faker: Faker, non_default: Any, default: Any = None, p_value=0.5):
|
||||||
|
if faker.pyfloat(min_value=0.0, max_value=1.0) < p_value:
|
||||||
|
return default
|
||||||
|
return non_default
|
||||||
|
|
||||||
|
|
||||||
def _amount() -> Decimal:
|
def _amount() -> Decimal:
|
||||||
return B4wExportFactory.__faker__.pydecimal(
|
return B4wExportFactory.__faker__.pydecimal(
|
||||||
left_digits=6,
|
left_digits=6,
|
||||||
@@ -34,11 +42,9 @@ def _iban() -> str:
|
|||||||
return B4wExportFactory.__faker__.iban()
|
return B4wExportFactory.__faker__.iban()
|
||||||
|
|
||||||
|
|
||||||
def _other_iban() -> str:
|
def _iban_or_none() -> str:
|
||||||
faker = B4wExportFactory.__faker__
|
faker = B4wExportFactory.__faker__
|
||||||
if faker.pyint(min_value=0, max_value=100) < 50:
|
return _faker_or_none(faker, faker.iban(), default="")
|
||||||
return ""
|
|
||||||
return faker.iban()
|
|
||||||
|
|
||||||
|
|
||||||
class B4wExportFactory(ModelFactory[B4wExport]):
|
class B4wExportFactory(ModelFactory[B4wExport]):
|
||||||
@@ -50,7 +56,7 @@ class B4wExportFactory(ModelFactory[B4wExport]):
|
|||||||
Notes = Use(_sentence)
|
Notes = Use(_sentence)
|
||||||
RmtdNm = Use(_names)
|
RmtdNm = Use(_names)
|
||||||
OwnrAcctIBAN = Use(_iban)
|
OwnrAcctIBAN = Use(_iban)
|
||||||
RmtdAcctIBAN = Use(_other_iban)
|
RmtdAcctIBAN = Use(_iban_or_none)
|
||||||
|
|
||||||
|
|
||||||
class ComdirectGiroFactory(ModelFactory[ComdirectGiro]):
|
class ComdirectGiroFactory(ModelFactory[ComdirectGiro]):
|
||||||
|
|||||||
Reference in New Issue
Block a user