mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
also split YAML-based tests into raster and vector and run them as part
of the corresponding algorithms test
This commit is contained in:
parent
f16f7f765e
commit
543673c388
@ -42,7 +42,6 @@ from qgis.core import (QgsProcessingContext,
|
||||
from qgis.testing import (start_app,
|
||||
unittest)
|
||||
|
||||
import AlgorithmsTestBase
|
||||
from processing.algs.gdal.GdalUtils import GdalUtils
|
||||
from processing.algs.gdal.ogr2ogr import ogr2ogr
|
||||
from processing.algs.gdal.OgrToPostGis import OgrToPostGis
|
||||
@ -50,7 +49,7 @@ from processing.algs.gdal.OgrToPostGis import OgrToPostGis
|
||||
testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')
|
||||
|
||||
|
||||
class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||
class TestGdalAlgorithms(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@ -64,9 +63,6 @@ class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||
for path in cls.cleanup_paths:
|
||||
shutil.rmtree(path)
|
||||
|
||||
def test_definition_file(self):
|
||||
return 'gdal_algorithm_tests.yaml'
|
||||
|
||||
def testCommandName(self):
|
||||
# Test that algorithms report a valid commandName
|
||||
p = QgsApplication.processingRegistry().providerById('gdal')
|
||||
|
@ -33,6 +33,7 @@ from qgis.core import (QgsProcessingContext,
|
||||
from qgis.testing import (start_app,
|
||||
unittest)
|
||||
|
||||
import AlgorithmsTestBase
|
||||
from processing.algs.gdal.AssignProjection import AssignProjection
|
||||
from processing.algs.gdal.ClipRasterByExtent import ClipRasterByExtent
|
||||
from processing.algs.gdal.ClipRasterByMask import ClipRasterByMask
|
||||
@ -70,7 +71,7 @@ from processing.algs.gdal.slope import slope
|
||||
testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')
|
||||
|
||||
|
||||
class TestGdalRasterAlgorithms(unittest.TestCase):
|
||||
class TestGdalRasterAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@ -84,6 +85,9 @@ class TestGdalRasterAlgorithms(unittest.TestCase):
|
||||
for path in cls.cleanup_paths:
|
||||
shutil.rmtree(path)
|
||||
|
||||
def test_definition_file(self):
|
||||
return 'gdal_algorithm_raster_tests.yaml'
|
||||
|
||||
def testAssignProjection(self):
|
||||
context = QgsProcessingContext()
|
||||
feedback = QgsProcessingFeedback()
|
||||
@ -2384,5 +2388,6 @@ class TestGdalRasterAlgorithms(unittest.TestCase):
|
||||
'-input_file_list buildvrtInputFiles.txt ' +
|
||||
outdir + '/check.vrt'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
nose2.main()
|
||||
|
@ -34,6 +34,7 @@ from qgis.core import (QgsProcessingContext,
|
||||
from qgis.testing import (start_app,
|
||||
unittest)
|
||||
|
||||
import AlgorithmsTestBase
|
||||
from processing.algs.gdal.ogr2ogr import ogr2ogr
|
||||
from processing.algs.gdal.ogrinfo import ogrinfo
|
||||
from processing.algs.gdal.Buffer import Buffer
|
||||
@ -46,7 +47,7 @@ from processing.algs.gdal.PointsAlongLines import PointsAlongLines
|
||||
testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')
|
||||
|
||||
|
||||
class TestGdalVectorAlgorithms(unittest.TestCase):
|
||||
class TestGdalVectorAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@ -60,6 +61,9 @@ class TestGdalVectorAlgorithms(unittest.TestCase):
|
||||
for path in cls.cleanup_paths:
|
||||
shutil.rmtree(path)
|
||||
|
||||
def test_definition_file(self):
|
||||
return 'gdal_algorithm_vector_tests.yaml'
|
||||
|
||||
def testOgr2Ogr(self):
|
||||
context = QgsProcessingContext()
|
||||
feedback = QgsProcessingFeedback()
|
||||
|
@ -431,282 +431,3 @@ tests:
|
||||
OUTPUT:
|
||||
hash: 6ced822cc490c7a3d9346b6c8cd4b282eb4e2a9fdd6e7371f6174117
|
||||
type: rasterhash
|
||||
|
||||
# - algorithm: gdal:merge
|
||||
# name: Merge 2 raster layers
|
||||
# params:
|
||||
# INPUT:
|
||||
# params:
|
||||
# - name: custom/dem_to_merge1.tif
|
||||
# type: raster
|
||||
# - name: custom/dem_to_merge2.tif
|
||||
# type: raster
|
||||
# type: multi
|
||||
# PCT: false
|
||||
# RTYPE: '5'
|
||||
# SEPARATE: false
|
||||
# results:
|
||||
# OUTPUT:
|
||||
# hash: fb6f0f4081308cc188eda2fbe106e04e0ebf866fc56853f0cca8db1c
|
||||
# type: rasterhash
|
||||
#
|
||||
# - algorithm: gdal:rastercalculator
|
||||
# name: Simple Raster Calculator test with only 1 raster
|
||||
# params:
|
||||
# BAND_A: '1'
|
||||
# FORMULA: A/2
|
||||
# INPUT_A:
|
||||
# name: dem.tif
|
||||
# type: raster
|
||||
# RTYPE: '5'
|
||||
# results:
|
||||
# OUTPUT:
|
||||
# hash: 2d0585dc8166fbe3cec7d9e6fd66e95cc9bdb1043b3b0fa7cbdfef4c
|
||||
# type: rasterhash
|
||||
|
||||
- algorithm: gdal:buffervectors
|
||||
name: Buffer lines
|
||||
params:
|
||||
DISSOLVE: false
|
||||
DISTANCE: 0.5
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/buffer_lines.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:buffervectors
|
||||
name: BUffer lines with dissolve
|
||||
params:
|
||||
DISSOLVE: true
|
||||
DISTANCE: 1.0
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/buffer_lines_dissolve.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:buffervectors
|
||||
name: Buffer polygons
|
||||
params:
|
||||
DISSOLVE: false
|
||||
DISTANCE: 0.5
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: polys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/buffer_polys.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:buffervectors
|
||||
name: Buffer polygons with dissolve
|
||||
params:
|
||||
DISSOLVE: true
|
||||
DISTANCE: 0.5
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: polys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/buffer_polys_dissolve.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:clipvectorbyextent
|
||||
name: Clip points by extent
|
||||
params:
|
||||
EXTENT: 0.6180722891566264,5.408433734939758,0.4337349397590362,2.306024096385542
|
||||
[EPSG:4326]
|
||||
INPUT:
|
||||
name: points.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/clip_points.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:clipvectorbyextent
|
||||
name: Clip lines by extent
|
||||
params:
|
||||
EXTENT: 4.362348178137652,8.698380566801621,-1.193522267206478,3.0914979757085024
|
||||
[EPSG:4326]
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/clip_lines.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:clipvectorbyextent
|
||||
name: Clip polygons by extent
|
||||
params:
|
||||
EXTENT: 0.7143072289156609,4.718222891566264,1.4430722891566266,5.390060240963856
|
||||
[EPSG:4326]
|
||||
INPUT:
|
||||
name: polys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/clip_polygons.gml
|
||||
type: vector
|
||||
|
||||
# Fail on Travis with
|
||||
# ERROR 1: TopologyException: Input geom 1 is invalid: Self-intersection at or near point 2 -1 at 2 -1
|
||||
# - algorithm: gdal:clipvectorbypolygon
|
||||
# name: Clip points by polygons
|
||||
# params:
|
||||
# INPUT:
|
||||
# name: points.gml
|
||||
# type: vector
|
||||
# MASK:
|
||||
# name: polys.gml
|
||||
# type: vector
|
||||
# OPTIONS: ''
|
||||
# results:
|
||||
# OUTPUT:
|
||||
# name: expected/gdal/clip_points_by_polygon.gml
|
||||
# type: vector
|
||||
#
|
||||
# - algorithm: gdal:clipvectorbypolygon
|
||||
# name: Clip lines by polygons
|
||||
# params:
|
||||
# INPUT:
|
||||
# name: lines.gml
|
||||
# type: vector
|
||||
# MASK:
|
||||
# name: polys.gml
|
||||
# type: vector
|
||||
# OPTIONS: ''
|
||||
# results:
|
||||
# OUTPUT:
|
||||
# name: expected/gdal/clip_lines_by_polygon.gml
|
||||
# type: vector
|
||||
|
||||
- algorithm: gdal:clipvectorbypolygon
|
||||
name: Clip lines by multipolygons
|
||||
params:
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
MASK:
|
||||
name: multipolys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/clip_lines_by_multipolygon.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:executesql
|
||||
name: Execute SQL
|
||||
params:
|
||||
DIALECT: 0
|
||||
INPUT:
|
||||
name: polys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
SQL: SELECT * FROM polys2 WHERE intval=2
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/execute_sql.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:offsetcurve
|
||||
name: Offset curve (right-sided)
|
||||
params:
|
||||
DISTANCE: -0.5
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/offset_lines.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:ogrinfo
|
||||
name: ogrinfo
|
||||
params:
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
SUMMARY_ONLY: 'True'
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/vector_info.html
|
||||
type: regex
|
||||
rules:
|
||||
- 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)'
|
||||
- 'Geometry: Line String'
|
||||
- 'Feature Count: [6|7]' # On some platforms returns 6 instead of 7...
|
||||
|
||||
- algorithm: gdal:onesidebuffer
|
||||
name: One-sided buffer (left-handed)
|
||||
params:
|
||||
BUFFER_SIDE: 1
|
||||
DISSOLVE: false
|
||||
DISTANCE: 0.5
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/one_side_buffer.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:pointsalonglines
|
||||
name: Points along lines
|
||||
params:
|
||||
DISTANCE: 0.25
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/points_along_lines.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:dissolve
|
||||
name: Dissolve points (multipoint output)
|
||||
params:
|
||||
COMPUTE_AREA: false
|
||||
COMPUTE_STATISTICS: false
|
||||
COUNT_FEATURES: false
|
||||
EXPLODE_COLLECTIONS: false
|
||||
FIELD: TestField
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: custom/dissolve_points.shp
|
||||
type: vector
|
||||
KEEP_ATTRIBUTES: false
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/dissolved_points.gml
|
||||
type: vector
|
248
python/plugins/processing/tests/testdata/gdal_algorithm_vector_tests.yaml
vendored
Normal file
248
python/plugins/processing/tests/testdata/gdal_algorithm_vector_tests.yaml
vendored
Normal file
@ -0,0 +1,248 @@
|
||||
tests:
|
||||
|
||||
- algorithm: gdal:buffervectors
|
||||
name: Buffer lines
|
||||
params:
|
||||
DISSOLVE: false
|
||||
DISTANCE: 0.5
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/buffer_lines.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:buffervectors
|
||||
name: BUffer lines with dissolve
|
||||
params:
|
||||
DISSOLVE: true
|
||||
DISTANCE: 1.0
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/buffer_lines_dissolve.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:buffervectors
|
||||
name: Buffer polygons
|
||||
params:
|
||||
DISSOLVE: false
|
||||
DISTANCE: 0.5
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: polys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/buffer_polys.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:buffervectors
|
||||
name: Buffer polygons with dissolve
|
||||
params:
|
||||
DISSOLVE: true
|
||||
DISTANCE: 0.5
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: polys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/buffer_polys_dissolve.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:clipvectorbyextent
|
||||
name: Clip points by extent
|
||||
params:
|
||||
EXTENT: 0.6180722891566264,5.408433734939758,0.4337349397590362,2.306024096385542
|
||||
[EPSG:4326]
|
||||
INPUT:
|
||||
name: points.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/clip_points.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:clipvectorbyextent
|
||||
name: Clip lines by extent
|
||||
params:
|
||||
EXTENT: 4.362348178137652,8.698380566801621,-1.193522267206478,3.0914979757085024
|
||||
[EPSG:4326]
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/clip_lines.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:clipvectorbyextent
|
||||
name: Clip polygons by extent
|
||||
params:
|
||||
EXTENT: 0.7143072289156609,4.718222891566264,1.4430722891566266,5.390060240963856
|
||||
[EPSG:4326]
|
||||
INPUT:
|
||||
name: polys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/clip_polygons.gml
|
||||
type: vector
|
||||
|
||||
# Fail on Travis with
|
||||
# ERROR 1: TopologyException: Input geom 1 is invalid: Self-intersection at or near point 2 -1 at 2 -1
|
||||
# - algorithm: gdal:clipvectorbypolygon
|
||||
# name: Clip points by polygons
|
||||
# params:
|
||||
# INPUT:
|
||||
# name: points.gml
|
||||
# type: vector
|
||||
# MASK:
|
||||
# name: polys.gml
|
||||
# type: vector
|
||||
# OPTIONS: ''
|
||||
# results:
|
||||
# OUTPUT:
|
||||
# name: expected/gdal/clip_points_by_polygon.gml
|
||||
# type: vector
|
||||
#
|
||||
# - algorithm: gdal:clipvectorbypolygon
|
||||
# name: Clip lines by polygons
|
||||
# params:
|
||||
# INPUT:
|
||||
# name: lines.gml
|
||||
# type: vector
|
||||
# MASK:
|
||||
# name: polys.gml
|
||||
# type: vector
|
||||
# OPTIONS: ''
|
||||
# results:
|
||||
# OUTPUT:
|
||||
# name: expected/gdal/clip_lines_by_polygon.gml
|
||||
# type: vector
|
||||
|
||||
- algorithm: gdal:clipvectorbypolygon
|
||||
name: Clip lines by multipolygons
|
||||
params:
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
MASK:
|
||||
name: multipolys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/clip_lines_by_multipolygon.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:executesql
|
||||
name: Execute SQL
|
||||
params:
|
||||
DIALECT: 0
|
||||
INPUT:
|
||||
name: polys.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
SQL: SELECT * FROM polys2 WHERE intval=2
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/execute_sql.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:offsetcurve
|
||||
name: Offset curve (right-sided)
|
||||
params:
|
||||
DISTANCE: -0.5
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/offset_lines.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:ogrinfo
|
||||
name: ogrinfo
|
||||
params:
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
SUMMARY_ONLY: 'True'
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/vector_info.html
|
||||
type: regex
|
||||
rules:
|
||||
- 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)'
|
||||
- 'Geometry: Line String'
|
||||
- 'Feature Count: [6|7]' # On some platforms returns 6 instead of 7...
|
||||
|
||||
- algorithm: gdal:onesidebuffer
|
||||
name: One-sided buffer (left-handed)
|
||||
params:
|
||||
BUFFER_SIDE: 1
|
||||
DISSOLVE: false
|
||||
DISTANCE: 0.5
|
||||
EXPLODE_COLLECTIONS: false
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/one_side_buffer.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:pointsalonglines
|
||||
name: Points along lines
|
||||
params:
|
||||
DISTANCE: 0.25
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: lines.gml
|
||||
type: vector
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/points_along_lines.gml
|
||||
type: vector
|
||||
|
||||
- algorithm: gdal:dissolve
|
||||
name: Dissolve points (multipoint output)
|
||||
params:
|
||||
COMPUTE_AREA: false
|
||||
COMPUTE_STATISTICS: false
|
||||
COUNT_FEATURES: false
|
||||
EXPLODE_COLLECTIONS: false
|
||||
FIELD: TestField
|
||||
GEOMETRY: geometry
|
||||
INPUT:
|
||||
name: custom/dissolve_points.shp
|
||||
type: vector
|
||||
KEEP_ATTRIBUTES: false
|
||||
OPTIONS: ''
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/dissolved_points.gml
|
||||
type: vector
|
Loading…
x
Reference in New Issue
Block a user