def test_execute(self): query = BulkInsertQuery(TestTable.name, columns_c) mock = get_mock_connection() rows = get_fake_rows(random.randrange(5, 10)) res = query.execute(lambda: mock, rows) assert res == len(rows) mock.commit.assert_called_once_with()
def test_error_invalid_data_width(self): q = BulkInsertQuery(TestTable.name, ColumnCollection(columns_t[:-1])) with self.assertRaises(ValueError): q.execute(get_mock_connection, get_fake_rows(5))
def test_error_no_data(self): query = BulkInsertQuery(TestTable.name, columns_c) with self.assertRaises(ValueError): query.execute(get_mock_connection, [])