diff --git a/python/plugins/processing/tests/testdata/expected/select_by_expression.gfs b/python/plugins/processing/tests/testdata/expected/select_by_expression.gfs new file mode 100644 index 000000000000..b4220f846b62 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/select_by_expression.gfs @@ -0,0 +1,26 @@ + + + select_by_expression + select_by_expression + + 1 + EPSG:4326 + + 2 + 0.00000 + 7.00000 + -1.00000 + -1.00000 + + + id + id + Integer + + + id2 + id2 + Integer + + + diff --git a/python/plugins/processing/tests/testdata/expected/select_by_expression.gml b/python/plugins/processing/tests/testdata/expected/select_by_expression.gml new file mode 100644 index 000000000000..33b3501b126a --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/select_by_expression.gml @@ -0,0 +1,28 @@ + + + + + 0-1 + 7-1 + + + + + + 0,-1 + 9 + 0 + + + + + 7,-1 + 8 + 0 + + + diff --git a/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml b/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml index 24a0597766d0..d0eeb549cdd6 100644 --- a/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml +++ b/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml @@ -2554,4 +2554,35 @@ tests: results: OUTPUT_LAYER: name: expected/selected_points.gml - type: vector \ No newline at end of file + 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: + INPUT: + name: custom/points_weighted.gml + type: vector + METHOD: '0' + NUMBER: 4 + results: {} + + - algorithm: qgis:randomextract + name: Random extract by percentage + params: + INPUT: + name: custom/points_weighted.gml + type: vector + METHOD: '1' + NUMBER: 50 + results: {} diff --git a/python/plugins/processing/tests/testdata/scripts/selectbyexpression.py b/python/plugins/processing/tests/testdata/scripts/selectbyexpression.py new file mode 100644 index 000000000000..c45b5d1768df --- /dev/null +++ b/python/plugins/processing/tests/testdata/scripts/selectbyexpression.py @@ -0,0 +1,15 @@ +##Select by expression=name +##Tests=group +##INPUT_LAYER=vector +##OUTPUT_LAYER=output vector + +import processing + +result = processing.run("qgis:selectbyexpression", + INPUT_LAYER, + '"id2" = 0 and "id" > 7', + "1") + +processing.run("qgis:saveselectedfeatures", + result["RESULT"], + OUTPUT_LAYER)