Skip to content

Commit

Permalink
[processing] add unittest for gdal2xyz algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jan 1, 2019
1 parent 655dc1f commit f447745
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
33 changes: 33 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsTest.py
Expand Up @@ -61,6 +61,7 @@
from processing.algs.gdal.rearrange_bands import rearrange_bands
from processing.algs.gdal.gdaladdo import gdaladdo
from processing.algs.gdal.sieve import sieve
from processing.algs.gdal.gdal2xyz import gdal2xyz

from processing.tools.system import isWindows

Expand Down Expand Up @@ -2514,6 +2515,38 @@ def testSieve(self):
source + ' ' +
outsource])

def testGdal2Xyz(self):
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()
source = os.path.join(testDataPath, 'dem.tif')

with tempfile.TemporaryDirectory() as outdir:
outsource = outdir + '/check.csv'
alg = gdal2xyz()
alg.initAlgorithm()

# defaults
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'BAND': 1,
'CSV': False,
'OUTPUT': outsource}, context, feedback),
['gdal2xyz.py',
'-band 1 ' +
source + ' ' +
outsource])

# csv output
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'BAND': 1,
'CSV': True,
'OUTPUT': outsource}, context, feedback),
['gdal2xyz.py',
'-band 1 -csv ' +
source + ' ' +
outsource])


class TestGdalOgrToPostGis(unittest.TestCase):

Expand Down
14 changes: 0 additions & 14 deletions python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml
Expand Up @@ -168,20 +168,6 @@ tests:
- 'Band 1 Block=373x5 Type=Float32, ColorInterp=Gray'
- ' NoData Value=-99999'

# Disabled as gdal2xyz.py is not available on Travis
# - algorithm: gdal:gdal2xyz
# name: gdal2xyz
# params:
# BAND: 1
# CSV: false
# INPUT:
# name: dem.tif
# type: raster
# results:
# OUTPUT:
# name: expected/gdal/xyz.csv
# type: file

- algorithm: gdal:tileindex
name: Tile index (gdaltindex)
params:
Expand Down

0 comments on commit f447745

Please sign in to comment.