changing temp location in the settings an recalculate the temp file path

This commit is contained in:
David Signer 2019-11-28 09:34:08 +01:00 committed by Nyall Dawson
parent ef8e251cf8
commit e465168539

View File

@ -8206,6 +8206,32 @@ void TestQgsProcessing::tempUtils()
QString tempFile3 = QgsProcessingUtils::generateTempFilename( "mybad:file.txt" );
QVERIFY( tempFile3.endsWith( "mybad_file.txt" ) );
QVERIFY( tempFile3.startsWith( tempFolder ) );
// change temp folder in the settings
QgsSettings settings;
QString alternative_tempFolder1 = QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/alternative_temp_test_one" );
settings.setValue( QStringLiteral( "Processing/Configuration/TEMP_PATH" ), alternative_tempFolder1 );
// check folder and if it's constant with alternative temp folder 1
tempFolder = QgsProcessingUtils::tempFolder();
QVERIFY( tempFolder.startsWith( alternative_tempFolder1 ) );
QCOMPARE( QgsProcessingUtils::tempFolder(), tempFolder );
// create file
QString alternativeTempFile1 = QgsProcessingUtils::generateTempFilename( "alternative_temptest.txt" );
QVERIFY( alternativeTempFile1.endsWith( "alternative_temptest.txt" ) );
QVERIFY( alternativeTempFile1.startsWith( tempFolder ) );
QVERIFY( alternativeTempFile1.startsWith( alternative_tempFolder1 ) );
// change temp folder in the settings again
QString alternative_tempFolder2 = QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/alternative_temp_test_two" );
settings.setValue( QStringLiteral( "Processing/Configuration/TEMP_PATH" ), alternative_tempFolder2 );
// check folder and if it's constant constant with alternative temp folder 2
tempFolder = QgsProcessingUtils::tempFolder();
QVERIFY( tempFolder.startsWith( alternative_tempFolder2 ) );
QCOMPARE( QgsProcessingUtils::tempFolder(), tempFolder );
// create file
QString alternativeTempFile2 = QgsProcessingUtils::generateTempFilename( "alternative_temptest.txt" );
QVERIFY( alternativeTempFile2.endsWith( "alternative_temptest.txt" ) );
QVERIFY( alternativeTempFile2.startsWith( tempFolder ) );
QVERIFY( alternativeTempFile2.startsWith( alternative_tempFolder2 ) );
}
void TestQgsProcessing::convertCompatible()