Skip to content

Commit f447745

Browse files
committed
[processing] add unittest for gdal2xyz algorithm
1 parent 655dc1f commit f447745

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

python/plugins/processing/tests/GdalAlgorithmsTest.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
from processing.algs.gdal.rearrange_bands import rearrange_bands
6262
from processing.algs.gdal.gdaladdo import gdaladdo
6363
from processing.algs.gdal.sieve import sieve
64+
from processing.algs.gdal.gdal2xyz import gdal2xyz
6465

6566
from processing.tools.system import isWindows
6667

@@ -2514,6 +2515,38 @@ def testSieve(self):
25142515
source + ' ' +
25152516
outsource])
25162517

2518+
def testGdal2Xyz(self):
2519+
context = QgsProcessingContext()
2520+
feedback = QgsProcessingFeedback()
2521+
source = os.path.join(testDataPath, 'dem.tif')
2522+
2523+
with tempfile.TemporaryDirectory() as outdir:
2524+
outsource = outdir + '/check.csv'
2525+
alg = gdal2xyz()
2526+
alg.initAlgorithm()
2527+
2528+
# defaults
2529+
self.assertEqual(
2530+
alg.getConsoleCommands({'INPUT': source,
2531+
'BAND': 1,
2532+
'CSV': False,
2533+
'OUTPUT': outsource}, context, feedback),
2534+
['gdal2xyz.py',
2535+
'-band 1 ' +
2536+
source + ' ' +
2537+
outsource])
2538+
2539+
# csv output
2540+
self.assertEqual(
2541+
alg.getConsoleCommands({'INPUT': source,
2542+
'BAND': 1,
2543+
'CSV': True,
2544+
'OUTPUT': outsource}, context, feedback),
2545+
['gdal2xyz.py',
2546+
'-band 1 -csv ' +
2547+
source + ' ' +
2548+
outsource])
2549+
25172550

25182551
class TestGdalOgrToPostGis(unittest.TestCase):
25192552

python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,6 @@ tests:
168168
- 'Band 1 Block=373x5 Type=Float32, ColorInterp=Gray'
169169
- ' NoData Value=-99999'
170170

171-
# Disabled as gdal2xyz.py is not available on Travis
172-
# - algorithm: gdal:gdal2xyz
173-
# name: gdal2xyz
174-
# params:
175-
# BAND: 1
176-
# CSV: false
177-
# INPUT:
178-
# name: dem.tif
179-
# type: raster
180-
# results:
181-
# OUTPUT:
182-
# name: expected/gdal/xyz.csv
183-
# type: file
184-
185171
- algorithm: gdal:tileindex
186172
name: Tile index (gdaltindex)
187173
params:

0 commit comments

Comments
 (0)