Skip to content

Commit

Permalink
Restore script based algorithm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 27, 2017
1 parent ae82985 commit e171fe3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 39 deletions.
46 changes: 23 additions & 23 deletions python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
Expand Up @@ -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:
Expand Down
@@ -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']
@@ -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']

0 comments on commit e171fe3

Please sign in to comment.