comdirect complete dummy generation
This commit is contained in:
@@ -4,10 +4,10 @@ from pathlib import Path
|
||||
from tests.factories import B4wExportFactory
|
||||
|
||||
NUMBER_OF_ROWS = 50
|
||||
PATH_DEFAULT = Path("tests/test_data/b4w_export_dummy_01.csv")
|
||||
DEFAULT_PATH = Path("tests/test_data/b4w_export_dummy_01.csv")
|
||||
|
||||
|
||||
def save_csv(path: Path = PATH_DEFAULT):
|
||||
def save_csv(path: Path = DEFAULT_PATH):
|
||||
data = B4wExportFactory.batch(NUMBER_OF_ROWS)
|
||||
row_fields = list(data[0].parameters_to_dict())
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
from pathlib import Path
|
||||
|
||||
from tests.factories import (
|
||||
ComdirectCreditCardFactory,
|
||||
ComdirectDepotFactory,
|
||||
ComdirectGiroFactory,
|
||||
)
|
||||
|
||||
DEFAULT_PATH = Path("tests/test_data/comdirect_export_dummy_01.txt")
|
||||
TEMPLATE_PATH = Path("scripts/dummy_data/comdirect_export_template.txt")
|
||||
|
||||
NUMBER_OF_ROWS_GIRO = 50
|
||||
NUMBER_OF_ROWS_CREDIT = 20
|
||||
NUMBER_OF_ROWS_TAGESGELD = 10
|
||||
NUMBER_OF_ROWS_DEPOT = 10
|
||||
|
||||
|
||||
def save(path: Path = DEFAULT_PATH):
|
||||
with TEMPLATE_PATH.open("r", encoding="latin-1") as fid:
|
||||
txt_temp = fid.read()
|
||||
assert isinstance(txt_temp, str)
|
||||
|
||||
batches = {
|
||||
"giro": {
|
||||
"data": ComdirectGiroFactory.batch(NUMBER_OF_ROWS_GIRO),
|
||||
"table_txt": "",
|
||||
},
|
||||
"credit": {
|
||||
"data": ComdirectCreditCardFactory.batch(NUMBER_OF_ROWS_CREDIT),
|
||||
"table_txt": "",
|
||||
},
|
||||
"tagesgled": {
|
||||
"data": ComdirectGiroFactory.batch(NUMBER_OF_ROWS_TAGESGELD),
|
||||
"table_txt": "",
|
||||
},
|
||||
"depot": {
|
||||
"data": ComdirectDepotFactory.batch(NUMBER_OF_ROWS_DEPOT),
|
||||
"table_txt": "",
|
||||
},
|
||||
}
|
||||
|
||||
for batch in batches.values():
|
||||
data = batch.get("data")
|
||||
assert isinstance(data, list)
|
||||
lines = [data[0].get_orig_headers()]
|
||||
lines = lines + [row.get_orig_row() for row in data]
|
||||
batch["table_txt"] = "\n".join(lines)
|
||||
|
||||
txt = txt_temp.format(
|
||||
table_giro=batches["giro"]["table_txt"],
|
||||
table_credit_card=batches["credit"]["table_txt"],
|
||||
table_tagesgeld=batches["tagesgled"]["table_txt"],
|
||||
table_depot=batches["depot"]["table_txt"],
|
||||
)
|
||||
|
||||
with path.open("w", newline="") as fid:
|
||||
fid.write(txt)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
save()
|
||||
Reference in New Issue
Block a user