def test_db_write(self, one_line_xlsx): from main.models import Bank for row in get_rows_from_blz_excel(data_file=one_line_xlsx): d = extract_data(row) dataset_number = d.pop('dataset_number') b, x = Bank.objects.get_or_create(dataset_number=dataset_number, defaults=d) assert b.name == 'Bundesbank'
def handle(self, *args, **options): from main.models import Bank from main.utils import get_rows_from_blz_excel, extract_data prev_bic = None for element in get_rows_from_blz_excel(): d = extract_data(element) dataset_number = d.pop("dataset_number") if not d.get("bic") and prev_bic: d["bic"] = prev_bic b, x = Bank.objects.update_or_create(dataset_number=dataset_number, defaults=d) prev_bic = d["bic"]
def handle(self, *args, **options): from main.models import Bank from main.utils import get_rows_from_blz_excel, extract_data prev_bic = None for element in get_rows_from_blz_excel(): d = extract_data(element) dataset_number = d.pop('dataset_number') if not d.get('bic') and prev_bic: d['bic'] = prev_bic b, x = Bank.objects.update_or_create(dataset_number=dataset_number, defaults=d) prev_bic = d['bic']
def test_processing(self, one_line_xlsx): for row in get_rows_from_blz_excel(data_file=one_line_xlsx): mapping = extract_data(row) assert len(mapping) == 13 assert mapping['name'] == 'Bundesbank' break