Skip to content

Commit 29ee893

Browse files
committed
[processing] add unittest for gdal2xyz algorithm
(cherry picked from commit f447745)
1 parent e39fdd5 commit 29ee893

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
@@ -167,20 +167,6 @@ tests:
167167
- 'Band 1 Block=373x5 Type=Float32, ColorInterp=Gray'
168168
- ' NoData Value=-99999'
169169

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

0 commit comments

Comments
 (0)