Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 8, 2021
1 parent 716e74c commit 9ee5e56
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions python/plugins/processing/tests/GdalAlgorithmsVectorTest.py
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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):
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -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',
Expand All @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -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):
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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()
Expand All @@ -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"'])


Expand Down

0 comments on commit 9ee5e56

Please sign in to comment.