Skip to content
Permalink
Browse files

[Processing][Test] QgsProcessingParameterFile description string

  • Loading branch information
rldhont committed May 4, 2021
1 parent e66e305 commit bb57221f9c7918b79bcb7ebf74ea910ad48beea7
Showing with 56 additions and 1 deletion.
  1. +56 −1 python/plugins/processing/tests/ParametersTest.py
@@ -25,7 +25,8 @@
import shutil

from qgis.core import (QgsProcessingParameterDefinition,
QgsProcessingParameterNumber)
QgsProcessingParameterNumber,
QgsProcessingParameterFile)
from qgis.testing import start_app, unittest

from processing.core.parameters import getParameterFromString
@@ -221,6 +222,60 @@ def testParameterExtentDesc(self):
self.assertIsNone(param.defaultValue())
self.assertTrue(param.flags() & QgsProcessingParameterDefinition.FlagOptional)

def testParameterFileDesc(self):
desc = 'QgsProcessingParameterFile|in_file|Input File'
param = getParameterFromString(desc)
self.assertIsNotNone(param)
self.assertEqual(param.type(), 'file')
self.assertEqual(param.name(), 'in_file')
self.assertEqual(param.description(), 'Input File')
self.assertEqual(param.behavior(), QgsProcessingParameterFile.File)
self.assertIsNone(param.defaultValue())
self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional)

desc = 'QgsProcessingParameterFile|in_folder|Input Folder|1'
param = getParameterFromString(desc)
self.assertIsNotNone(param)
self.assertEqual(param.type(), 'file')
self.assertEqual(param.name(), 'in_folder')
self.assertEqual(param.description(), 'Input Folder')
self.assertEqual(param.behavior(), QgsProcessingParameterFile.Folder)
self.assertIsNone(param.defaultValue())
self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional)

desc = 'QgsProcessingParameterFile|in_folder|Input Folder|QgsProcessingParameterFile.Folder'
param = getParameterFromString(desc)
self.assertIsNotNone(param)
self.assertEqual(param.type(), 'file')
self.assertEqual(param.name(), 'in_folder')
self.assertEqual(param.description(), 'Input Folder')
self.assertEqual(param.behavior(), QgsProcessingParameterFile.Folder)
self.assertIsNone(param.defaultValue())
self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional)

desc = 'QgsProcessingParameterFile|in_file|Input File|0|gpkg'
param = getParameterFromString(desc)
self.assertIsNotNone(param)
self.assertEqual(param.type(), 'file')
self.assertEqual(param.name(), 'in_file')
self.assertEqual(param.description(), 'Input File')
self.assertEqual(param.behavior(), QgsProcessingParameterFile.File)
self.assertEqual(param.extension(), 'gpkg')
self.assertIsNone(param.defaultValue())
self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional)

desc = 'QgsProcessingParameterFile|in_file|Input File|0|png|None|False|PNG Files (*.png);; JPG Files (*.jpg *.jpeg)'
param = getParameterFromString(desc)
self.assertIsNotNone(param)
self.assertEqual(param.type(), 'file')
self.assertEqual(param.name(), 'in_file')
self.assertEqual(param.description(), 'Input File')
self.assertEqual(param.behavior(), QgsProcessingParameterFile.File)
self.assertEqual(param.extension(), '')
self.assertIsNone(param.defaultValue())
self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional)
self.assertEqual(param.fileFilter(), 'PNG Files (*.png);; JPG Files (*.jpg *.jpeg)')


if __name__ == '__main__':
unittest.main()

0 comments on commit bb57221

Please sign in to comment.