[processing] add unittest for gdal2xyz algorithm

This commit is contained in:
Alexander Bruy 2019-01-01 18:15:41 +02:00
parent 655dc1f567
commit f447745b5f
2 changed files with 33 additions and 14 deletions

View File

@ -61,6 +61,7 @@ from processing.algs.gdal.fillnodata import fillnodata
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
@ -2514,6 +2515,38 @@ class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
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):

View File

@ -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: