Skip to content
Permalink
Browse files
Tests QgsProcessingParameterNumber
  • Loading branch information
rldhont authored and nyalldawson committed May 4, 2021
1 parent 7b97bd9 commit 44a5c973242c7a010e955f7a805e4a0a7d5d26b2
Showing with 39 additions and 0 deletions.
  1. +39 −0 python/plugins/processing/tests/ParametersTest.py
@@ -83,6 +83,45 @@ def testParameterStringDesc(self):
self.assertFalse(param.multiLine())
self.assertTrue(param.flags() & QgsProcessingParameterDefinition.FlagOptional)

def testParameterNumberDesc(self):
desc = 'QgsProcessingParameterNumber|in_number|Input number'
param = getParameterFromString(desc)
self.assertIsNotNone(param)
self.assertEqual(param.type(), 'number')
self.assertEqual(param.name(), 'in_number')
self.assertEqual(param.description(), 'Input Number')
self.assertEqual(param.dataType(), QgsProcessingParameterNumber.Integer)
self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional)

desc = 'QgsProcessingParameterNumber|in_number|Input number|QgsProcessingParameterNumber.Double'
param = getParameterFromString(desc)
self.assertIsNotNone(param)
self.assertEqual(param.type(), 'number')
self.assertEqual(param.name(), 'in_number')
self.assertEqual(param.description(), 'Input Number')
self.assertEqual(param.dataType(), QgsProcessingParameterNumber.Double)
self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional)

desc = 'QgsProcessingParameterNumber|in_number|Input number|QgsProcessingParameterNumber.Integer|10'
param = getParameterFromString(desc)
self.assertIsNotNone(param)
self.assertEqual(param.type(), 'number')
self.assertEqual(param.name(), 'in_number')
self.assertEqual(param.description(), 'Input Number')
self.assertEqual(param.dataType(), QgsProcessingParameterNumber.Integer)
self.assertEqual(param.defaultValue(), 10)
self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional)

desc = 'QgsProcessingParameterNumber|in_number|Input number|QgsProcessingParameterNumber.Integer|None|True'
param = getParameterFromString(desc)
self.assertIsNotNone(param)
self.assertEqual(param.type(), 'number')
self.assertEqual(param.name(), 'in_number')
self.assertEqual(param.description(), 'Input Number')
self.assertEqual(param.dataType(), QgsProcessingParameterNumber.Integer)
self.assertIsNone(param.defaultValue())
self.assertTrue(param.flags() & QgsProcessingParameterDefinition.FlagOptional)


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

0 comments on commit 44a5c97

Please sign in to comment.