File indexing completed on 2024-05-12 16:45:20
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 /** @file 0007 * This file is a test script. 0008 * 0009 * @author Stephane MANKOWSKI / Guillaume DE BURE 0010 */ 0011 #include "skgtestmacro.h" 0012 #include "skgbankincludes.h" 0013 #include "skgimportexportmanager.h" 0014 0015 /** 0016 * The main function of the import rule test 0017 * @param argc the number of arguments 0018 * @param argv the list of arguments 0019 */ 0020 int main(int argc, char** argv) 0021 { 0022 Q_UNUSED(argc) 0023 Q_UNUSED(argv) 0024 0025 // Init test 0026 SKGINITTEST(true) 0027 SKGError err; 0028 { 0029 // Test import SKGImportExportManager::CSV skrooge 0030 SKGDocumentBank document1; 0031 SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true) { 0032 // Scope of the transaction 0033 SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err) { 0034 SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportcsvrule/notfound.csv")); 0035 QMap<QString, QString> parameters = imp1.getImportParameters(); 0036 parameters[QStringLiteral("mode_csv_rule")] = 'Y'; 0037 imp1.setImportParameters(parameters); 0038 SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), false) // FILE NOT FOUND 0039 } 0040 { 0041 SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportcsvrule/test1.csv")); 0042 QMap<QString, QString> parameters = imp1.getImportParameters(); 0043 parameters[QStringLiteral("mode_csv_rule")] = 'Y'; 0044 imp1.setImportParameters(parameters); 0045 SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true) 0046 } 0047 } 0048 0049 int nb = 0; 0050 SKGTESTERROR(QStringLiteral("imp1.getNbObjects"), document1.getNbObjects(QStringLiteral("rule"), QLatin1String(""), nb), true) 0051 SKGTEST(QStringLiteral("imp1.nb"), nb, 3) 0052 } 0053 0054 // End test 0055 SKGENDTEST() 0056 }