|
26 | 26 |
|
27 | 27 | from qgis.core import (QgsProcessingParameterDefinition,
|
28 | 28 | QgsProcessingParameterNumber,
|
29 |
| - QgsProcessingParameterFile) |
| 29 | + QgsProcessingParameterFile, |
| 30 | + QgsProcessing) |
30 | 31 | from qgis.testing import start_app, unittest
|
31 | 32 |
|
32 | 33 | from processing.core.parameters import getParameterFromString
|
@@ -276,6 +277,117 @@ def testParameterFileDesc(self):
|
276 | 277 | self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional)
|
277 | 278 | self.assertEqual(param.fileFilter(), 'PNG Files (*.png);; JPG Files (*.jpg *.jpeg)')
|
278 | 279 |
|
| 280 | + def testParameterVectorDestDesc(self): |
| 281 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination' |
| 282 | + param = getParameterFromString(desc) |
| 283 | + self.assertIsNotNone(param) |
| 284 | + self.assertEqual(param.type(), 'vectorDestination') |
| 285 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 286 | + self.assertEqual(param.description(), 'Vector Destination') |
| 287 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVectorAnyGeometry) |
| 288 | + self.assertIsNone(param.defaultValue()) |
| 289 | + self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 290 | + self.assertTrue(param.createByDefault()) |
| 291 | + |
| 292 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination Point|0' |
| 293 | + param = getParameterFromString(desc) |
| 294 | + self.assertIsNotNone(param) |
| 295 | + self.assertEqual(param.type(), 'vectorDestination') |
| 296 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 297 | + self.assertEqual(param.description(), 'Vector Destination Point') |
| 298 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVectorPoint) |
| 299 | + self.assertIsNone(param.defaultValue()) |
| 300 | + self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 301 | + self.assertTrue(param.createByDefault()) |
| 302 | + |
| 303 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination Point|QgsProcessing.TypeVectorPoint' |
| 304 | + param = getParameterFromString(desc) |
| 305 | + self.assertIsNotNone(param) |
| 306 | + self.assertEqual(param.type(), 'vectorDestination') |
| 307 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 308 | + self.assertEqual(param.description(), 'Vector Destination Point') |
| 309 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVectorPoint) |
| 310 | + self.assertIsNone(param.defaultValue()) |
| 311 | + self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 312 | + self.assertTrue(param.createByDefault()) |
| 313 | + |
| 314 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination Line|1' |
| 315 | + param = getParameterFromString(desc) |
| 316 | + self.assertIsNotNone(param) |
| 317 | + self.assertEqual(param.type(), 'vectorDestination') |
| 318 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 319 | + self.assertEqual(param.description(), 'Vector Destination Line') |
| 320 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVectorLine) |
| 321 | + self.assertIsNone(param.defaultValue()) |
| 322 | + self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 323 | + self.assertTrue(param.createByDefault()) |
| 324 | + |
| 325 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination Line|QgsProcessing.TypeVectorLine' |
| 326 | + param = getParameterFromString(desc) |
| 327 | + self.assertIsNotNone(param) |
| 328 | + self.assertEqual(param.type(), 'vectorDestination') |
| 329 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 330 | + self.assertEqual(param.description(), 'Vector Destination Line') |
| 331 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVectorLine) |
| 332 | + self.assertIsNone(param.defaultValue()) |
| 333 | + self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 334 | + self.assertTrue(param.createByDefault()) |
| 335 | + |
| 336 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination Polygon|2' |
| 337 | + param = getParameterFromString(desc) |
| 338 | + self.assertIsNotNone(param) |
| 339 | + self.assertEqual(param.type(), 'vectorDestination') |
| 340 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 341 | + self.assertEqual(param.description(), 'Vector Destination Polygon') |
| 342 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVectorPolygon) |
| 343 | + self.assertIsNone(param.defaultValue()) |
| 344 | + self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 345 | + self.assertTrue(param.createByDefault()) |
| 346 | + |
| 347 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination Polygon|QgsProcessing.TypeVectorPolygon' |
| 348 | + param = getParameterFromString(desc) |
| 349 | + self.assertIsNotNone(param) |
| 350 | + self.assertEqual(param.type(), 'vectorDestination') |
| 351 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 352 | + self.assertEqual(param.description(), 'Vector Destination Polygon') |
| 353 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVectorPolygon) |
| 354 | + self.assertIsNone(param.defaultValue()) |
| 355 | + self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 356 | + self.assertTrue(param.createByDefault()) |
| 357 | + |
| 358 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination Table|5' |
| 359 | + param = getParameterFromString(desc) |
| 360 | + self.assertIsNotNone(param) |
| 361 | + self.assertEqual(param.type(), 'vectorDestination') |
| 362 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 363 | + self.assertEqual(param.description(), 'Vector Destination Table') |
| 364 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVector) |
| 365 | + self.assertIsNone(param.defaultValue()) |
| 366 | + self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 367 | + self.assertTrue(param.createByDefault()) |
| 368 | + |
| 369 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination Table|QgsProcessing.TypeVector' |
| 370 | + param = getParameterFromString(desc) |
| 371 | + self.assertIsNotNone(param) |
| 372 | + self.assertEqual(param.type(), 'vectorDestination') |
| 373 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 374 | + self.assertEqual(param.description(), 'Vector Destination Table') |
| 375 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVector) |
| 376 | + self.assertIsNone(param.defaultValue()) |
| 377 | + self.assertFalse(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 378 | + self.assertTrue(param.createByDefault()) |
| 379 | + |
| 380 | + desc = 'QgsProcessingParameterVectorDestination|param_vector_dest|Vector Destination|-1|None|True|False' |
| 381 | + param = getParameterFromString(desc) |
| 382 | + self.assertIsNotNone(param) |
| 383 | + self.assertEqual(param.type(), 'vectorDestination') |
| 384 | + self.assertEqual(param.name(), 'param_vector_dest') |
| 385 | + self.assertEqual(param.description(), 'Vector Destination') |
| 386 | + self.assertEqual(param.dataType(), QgsProcessing.TypeVectorAnyGeometry) |
| 387 | + self.assertIsNone(param.defaultValue()) |
| 388 | + self.assertTrue(param.flags() & QgsProcessingParameterDefinition.FlagOptional) |
| 389 | + self.assertFalse(param.createByDefault()) |
| 390 | + |
279 | 391 |
|
280 | 392 | if __name__ == '__main__':
|
281 | 393 | unittest.main()
|
0 commit comments