def test_header(self): rows = [columns] + get_fake_rows(5) bulk = BulkInsertFromIterator(TestTable, rows, columns_t, header=True) res = bulk.execute(get_mock_connection) assert res == len(rows) - 1
def test_header_missing_column(self): rows = [columns[:2]] + [(r[0], r[1]) for r in get_fake_rows(5)] bulk = BulkInsertFromIterator(TestTable, rows, columns_t, header=True) res = bulk.execute(get_mock_connection) assert res == len(rows) - 1 assert len(bulk.columns) == len(rows[0])
def test_batch(self): rows = get_fake_rows(100) batch_size = 5 batches_expected = math.ceil(len(rows) / batch_size) bulk = BulkInsertFromIterator(TestTable, rows, columns_t, batch_size) batches = [] for batch in bulk.batch_execute(get_mock_connection): batches.append(batch) assert len(batches) == batches_expected