Skip to content
Permalink
Browse files

Update tests

  • Loading branch information
nyalldawson committed Jan 8, 2021
1 parent 716e74c commit 9ee5e5646a0e2b7903ade01daf62f60bb6114c57
Showing with 47 additions and 47 deletions.
  1. +47 −47 python/plugins/processing/tests/GdalAlgorithmsVectorTest.py
@@ -158,7 +158,7 @@ def testBuffer(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_Buffer(geometry, 5.0) AS geometry,* FROM \\"polys2\\"" ' +
'-dialect sqlite -sql "SELECT ST_Buffer(geometry, 5.0) AS geometry,* FROM """polys2"""" ' +
'-f "ESRI Shapefile"'])

self.assertEqual(
@@ -169,7 +169,7 @@ def testBuffer(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_Union(ST_Buffer(geometry, 5.0)) AS geometry,* FROM \\"polys2\\"" ' +
'-dialect sqlite -sql "SELECT ST_Union(ST_Buffer(geometry, 5.0)) AS geometry,* FROM """polys2"""" ' +
'-f "ESRI Shapefile"'])

self.assertEqual(
@@ -180,7 +180,7 @@ def testBuffer(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_Buffer(geometry, 5.0) AS geometry,* FROM \\"polys2\\"" ' +
'-dialect sqlite -sql "SELECT ST_Buffer(geometry, 5.0) AS geometry,* FROM """polys2"""" ' +
'-explodecollections -f "ESRI Shapefile"'])

self.assertEqual(
@@ -192,7 +192,7 @@ def testBuffer(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_Union(ST_Buffer(geometry, 5.0)) AS geometry,* FROM \\"polys2\\" GROUP BY \\"total population\\"" ' +
'-dialect sqlite -sql "SELECT ST_Union(ST_Buffer(geometry, 5.0)) AS geometry,* FROM """polys2""" GROUP BY """total population"""" ' +
'-explodecollections -f "ESRI Shapefile"'])

def testDissolve(self):
@@ -210,7 +210,7 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry FROM \\"polys2\\"" ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry FROM """polys2"""" ' +
'-f "ESRI Shapefile"'])

self.assertEqual(
@@ -220,8 +220,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\" FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""" FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -230,8 +230,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"total population\\" FROM \\"polys2\\" ' +
'GROUP BY \\"total population\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """total population""" FROM """polys2""" ' +
'GROUP BY """total population"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source_with_space,
@@ -240,8 +240,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
'"' + source_with_space + '" ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\" FROM \\"filename_with_spaces\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""" FROM """filename_with_spaces""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -251,8 +251,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(the_geom) AS the_geom, \\"my_field\\" FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(the_geom) AS the_geom, """my_field""" FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -262,8 +262,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\" FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""" FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -272,7 +272,7 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry FROM \\"polys2\\"" ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry FROM """polys2"""" ' +
'-f "ESRI Shapefile"'])

self.assertEqual(
@@ -283,8 +283,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\" FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -explodecollections -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""" FROM """polys2""" ' +
'GROUP BY """my_field"""" -explodecollections -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -294,8 +294,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\", COUNT(geometry) AS count FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""", COUNT(geometry) AS count FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -306,8 +306,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(the_geom) AS the_geom, \\"my_field\\", COUNT(the_geom) AS count FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(the_geom) AS the_geom, """my_field""", COUNT(the_geom) AS count FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -317,9 +317,9 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\", SUM(ST_Area(geometry)) AS area, ' +
'ST_Perimeter(ST_Union(geometry)) AS perimeter FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""", SUM(ST_Area(geometry)) AS area, ' +
'ST_Perimeter(ST_Union(geometry)) AS perimeter FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -330,9 +330,9 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(the_geom) AS the_geom, \\"my_field\\", SUM(ST_Area(the_geom)) AS area, ' +
'ST_Perimeter(ST_Union(the_geom)) AS perimeter FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(the_geom) AS the_geom, """my_field""", SUM(ST_Area(the_geom)) AS area, ' +
'ST_Perimeter(ST_Union(the_geom)) AS perimeter FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -343,9 +343,9 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\", ' +
'SUM(\\"my_val\\") AS sum, MIN(\\"my_val\\") AS min, MAX(\\"my_val\\") AS max, AVG(\\"my_val\\") AS avg FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""", ' +
'SUM("""my_val""") AS sum, MIN("""my_val""") AS min, MAX("""my_val""") AS max, AVG("""my_val""") AS avg FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -356,10 +356,10 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"test field\\", ' +
'SUM(\\"total population\\") AS sum, MIN(\\"total population\\") AS min, MAX(\\"total population\\") AS max, ' +
'AVG(\\"total population\\") AS avg FROM \\"polys2\\" ' +
'GROUP BY \\"test field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """test field""", ' +
'SUM("""total population""") AS sum, MIN("""total population""") AS min, MAX("""total population""") AS max, ' +
'AVG("""total population""") AS avg FROM """polys2""" ' +
'GROUP BY """test field"""" -f "ESRI Shapefile"'])

# compute stats without stats attribute, and vice versa (should be ignored)
self.assertEqual(
@@ -370,8 +370,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\" FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""" FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'FIELD': 'my_field',
@@ -380,8 +380,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\" FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""" FROM """polys2""" ' +
'GROUP BY """my_field"""" -f "ESRI Shapefile"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -391,8 +391,8 @@ def testDissolve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, \\"my_field\\" FROM \\"polys2\\" ' +
'GROUP BY \\"my_field\\"" "my opts" -f "ESRI Shapefile"'])
'-nlt PROMOTE_TO_MULTI -dialect sqlite -sql "SELECT ST_Union(geometry) AS geometry, """my_field""" FROM """polys2""" ' +
'GROUP BY """my_field"""" "my opts" -f "ESRI Shapefile"'])

def testOgr2PostGis(self):
context = QgsProcessingContext()
@@ -749,7 +749,7 @@ def testOffsetCurve(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_OffsetCurve(geometry, 5.0) AS geometry,* FROM \\"polys2\\"" ' +
'-dialect sqlite -sql "SELECT ST_OffsetCurve(geometry, 5.0) AS geometry,* FROM """polys2"""" ' +
'-f "ESRI Shapefile"'])

def testOneSidedBuffer(self):
@@ -768,7 +768,7 @@ def testOneSidedBuffer(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_SingleSidedBuffer(geometry, 5.0, 0) AS geometry,* FROM \\"polys2\\"" ' +
'-dialect sqlite -sql "SELECT ST_SingleSidedBuffer(geometry, 5.0, 0) AS geometry,* FROM """polys2"""" ' +
'-f "ESRI Shapefile"'])

self.assertEqual(
@@ -779,7 +779,7 @@ def testOneSidedBuffer(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_Union(ST_SingleSidedBuffer(geometry, 5.0, 0)) AS geometry,* FROM \\"polys2\\"" ' +
'-dialect sqlite -sql "SELECT ST_Union(ST_SingleSidedBuffer(geometry, 5.0, 0)) AS geometry,* FROM """polys2"""" ' +
'-f "ESRI Shapefile"'])

self.assertEqual(
@@ -790,7 +790,7 @@ def testOneSidedBuffer(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_SingleSidedBuffer(geometry, 5.0, 0) AS geometry,* FROM \\"polys2\\"" ' +
'-dialect sqlite -sql "SELECT ST_SingleSidedBuffer(geometry, 5.0, 0) AS geometry,* FROM """polys2"""" ' +
'-explodecollections -f "ESRI Shapefile"'])

self.assertEqual(
@@ -802,7 +802,7 @@ def testOneSidedBuffer(self):
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_Union(ST_SingleSidedBuffer(geometry, 5.0, 0)) AS geometry,* ' +
'FROM \\"polys2\\" GROUP BY \\"total population\\"" -f "ESRI Shapefile"'])
'FROM """polys2""" GROUP BY """total population"""" -f "ESRI Shapefile"'])

def testPointsAlongLines(self):
context = QgsProcessingContext()
@@ -820,7 +820,7 @@ def testPointsAlongLines(self):
['ogr2ogr',
outdir + '/check.shp ' +
source + ' ' +
'-dialect sqlite -sql "SELECT ST_Line_Interpolate_Point(geometry, 0.2) AS geometry,* FROM \\"polys2\\"" ' +
'-dialect sqlite -sql "SELECT ST_Line_Interpolate_Point(geometry, 0.2) AS geometry,* FROM """polys2"""" ' +
'-f "ESRI Shapefile"'])


0 comments on commit 9ee5e56

Please sign in to comment.
You can’t perform that action at this time.