MCPcopy Create free account
hub / github.com/KDE/labplot / testQuery

Method testQuery

tests/import_export/SQL/ImportSqlDatabaseTest.cpp:290–314  ·  view source on GitHub ↗

############################################################################## ################## import the result of a custom query ###################### ##############################################################################

Source from the content-addressed store, hash-verified

288// ################## import the result of a custom query ######################
289// ##############################################################################
290void ImportSqlDatabaseTest::testQuery() {
291 // prepare the target spreadsheet
292 Spreadsheet spreadsheet(QStringLiteral("test"), false);
293
294 // import the resultset of a custom query
295 ImportSQLDatabaseWidget w;
296 w.loadSettings();
297 w.setCustomQuery(true);
298 w.setQuery(QLatin1String("select title from albums where title like '%best%';"));
299 w.refreshPreview();
300 w.read(&spreadsheet, AbstractFileFilter::ImportMode::Replace);
301
302 // check the spreadsheet size and columns names and modes
303 QCOMPARE(spreadsheet.rowCount(), 15);
304 QCOMPARE(spreadsheet.columnCount(), 1);
305
306 QCOMPARE(spreadsheet.column(0)->name(), QLatin1String("Title"));
307 QCOMPARE(spreadsheet.column(0)->columnMode(), AbstractColumn::ColumnMode::Text);
308
309 // first row in the spreadsheet
310 QCOMPARE(spreadsheet.column(0)->textAt(0), QLatin1String("The Best Of Billy Cobham"));
311
312 // last row in the spreadsheet
313 QCOMPARE(spreadsheet.column(0)->textAt(14), QLatin1String("The Best of Beethoven"));
314}
315
316// ##############################################################################
317// ################################# export ####################################

Callers

nothing calls this directly

Calls 11

setCustomQueryMethod · 0.80
setQueryMethod · 0.80
loadSettingsMethod · 0.45
refreshPreviewMethod · 0.45
readMethod · 0.45
rowCountMethod · 0.45
columnCountMethod · 0.45
nameMethod · 0.45
columnMethod · 0.45
columnModeMethod · 0.45
textAtMethod · 0.45

Tested by

no test coverage detected