Skip to content
Permalink
Browse files

[processing] Add unit test for gdalinfo algorithm

(cherry-picked from 16503b3)
  • Loading branch information
nyalldawson committed Aug 21, 2018
1 parent 821aad4 commit ee3dbee843d0962bd5f8bf1c85d819207ec42e4e
Showing with 63 additions and 0 deletions.
  1. +63 −0 python/plugins/processing/tests/GdalAlgorithmsTest.py
@@ -35,6 +35,7 @@
from processing.algs.gdal.gdalcalc import gdalcalc
from processing.algs.gdal.gdaltindex import gdaltindex
from processing.algs.gdal.contour import contour
from processing.algs.gdal.gdalinfo import gdalinfo
from processing.algs.gdal.GridAverage import GridAverage
from processing.algs.gdal.GridDataMetrics import GridDataMetrics
from processing.algs.gdal.GridInverseDistance import GridInverseDistance
@@ -804,6 +805,68 @@ def testBuildVrt(self):
self.assertIn('-input_file_list', commands[1])
self.assertIn('d:/temp/test.vrt', commands[1])

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

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'MIN_MAX': False,
'NOGCP': False,
'NO_METADATA': False,
'STATS': False}, context, feedback),
['gdalinfo',
source])

source = os.path.join(testDataPath, 'raster with spaces.tif')
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'MIN_MAX': False,
'NOGCP': False,
'NO_METADATA': False,
'STATS': False}, context, feedback),
['gdalinfo',
'"' + source + '"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'MIN_MAX': True,
'NOGCP': False,
'NO_METADATA': False,
'STATS': False}, context, feedback),
['gdalinfo',
'-mm "' + source + '"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'MIN_MAX': False,
'NOGCP': True,
'NO_METADATA': False,
'STATS': False}, context, feedback),
['gdalinfo',
'-nogcp "' + source + '"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'MIN_MAX': False,
'NOGCP': False,
'NO_METADATA': True,
'STATS': False}, context, feedback),
['gdalinfo',
'-nomd "' + source + '"'])

self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'MIN_MAX': False,
'NOGCP': False,
'NO_METADATA': False,
'STATS': True}, context, feedback),
['gdalinfo',
'-stats "' + source + '"'])

def testGdalTindex(self):
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()

0 comments on commit ee3dbee

Please sign in to comment.
You can’t perform that action at this time.