Restore script based algorithm tests

This commit is contained in:
Nyall Dawson 2017-06-27 13:05:16 +10:00
parent ae829857ca
commit e171fe30c0
3 changed files with 56 additions and 39 deletions

View File

@ -2542,29 +2542,29 @@ tests:
# MIN_DISTANCE: 0.0
# POINT_NUMBER: 5
# results: {}
#
# - algorithm: script:selectbyattribute
# name: Select by attribute
# params:
# INPUT_LAYER:
# name: points.gml
# type: vector
# results:
# OUTPUT_LAYER:
# name: expected/selected_points.gml
# type: vector
#
# - algorithm: script:selectbyexpression
# name: Select by expression
# params:
# INPUT_LAYER:
# name: points.gml
# type: vector
# results:
# OUTPUT_LAYER:
# name: expected/select_by_expression.gml
# type: vector
#
- algorithm: script:selectbyattribute
name: Select by attribute
params:
INPUT_LAYER:
name: points.gml
type: vector
results:
OUTPUT_LAYER:
name: expected/selected_points.gml
type: vector
- algorithm: script:selectbyexpression
name: Select by expression
params:
INPUT_LAYER:
name: points.gml
type: vector
results:
OUTPUT_LAYER:
name: expected/select_by_expression.gml
type: vector
- algorithm: qgis:randomextract
name: Random extract by number
params:

View File

@ -1,16 +1,23 @@
##Select by attribute=name
##Tests=group
#inputs
##INPUT_LAYER=vector
##OUTPUT_LAYER=output vector
##OUTPUT_LAYER=vectorOut
#outputs
##OUTPUT_LAYER=output outputVector
import processing
result = processing.run("qgis:selectbyattribute",
INPUT_LAYER,
"id2",
0,
"2")
processing.run("qgis:saveselectedfeatures",
result["OUTPUT"],
OUTPUT_LAYER)
{'INPUT': INPUT_LAYER,
'FIELD': "id2",
'OPERATOR': 0,
'VALUE': "2"}, context=context, feedback=feedback)
result = processing.run("qgis:saveselectedfeatures",
{'INPUT': result["OUTPUT"],
'OUTPUT': parameters['OUTPUT_LAYER']}, context=context, feedback=feedback)
OUTPUT_LAYER = result['OUTPUT']

View File

@ -1,15 +1,25 @@
##Select by expression=name
##Tests=group
#inputs
##INPUT_LAYER=vector
##OUTPUT_LAYER=output vector
##OUTPUT_LAYER=vectorOut
#outputs
##OUTPUT_LAYER=output outputVector
import processing
result = processing.run("qgis:selectbyexpression",
INPUT_LAYER,
'"id2" = 0 and "id" > 7',
"1")
{'INPUT': INPUT_LAYER,
'EXPRESSION': '"id2" = 0 and "id" > 7',
'METHOD': 1}, context=context, feedback=feedback)
processing.run("qgis:saveselectedfeatures",
result["RESULT"],
OUTPUT_LAYER)
result = processing.run("qgis:saveselectedfeatures",
{'INPUT': result["OUTPUT"],
'OUTPUT': parameters['OUTPUT_LAYER']},
context=context, feedback=feedback)
OUTPUT_LAYER = result['OUTPUT']