Skip to content

Commit b4f3b82

Browse files
luipirnyalldawson
authored andcommitted
Added test for gdal_fillnodata used inside processing
1 parent b9e5f4a commit b4f3b82

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

python/plugins/processing/tests/GdalAlgorithmsTest.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from processing.algs.gdal.retile import retile
5050
from processing.algs.gdal.translate import translate
5151
from processing.algs.gdal.warp import warp
52+
from processing.algs.gdal.fillnodata import fillnodata
5253

5354
from qgis.core import (QgsProcessingContext,
5455
QgsProcessingFeedback,
@@ -1340,6 +1341,59 @@ def testWarp(self):
13401341
source + ' ' +
13411342
'd:/temp/check.jpg'])
13421343

1344+
def testFillnodata(self):
1345+
context = QgsProcessingContext()
1346+
feedback = QgsProcessingFeedback()
1347+
source = os.path.join(testDataPath, 'dem.tif')
1348+
mask = os.path.join(testDataPath, 'raster.tif')
1349+
outsource = 'd:/temp/check.tif'
1350+
alg = fillnodata()
1351+
alg.initAlgorithm()
1352+
1353+
# with mask value
1354+
self.assertEqual(
1355+
alg.getConsoleCommands({'INPUT': source,
1356+
'BAND': 1,
1357+
'DISTANCE': 10,
1358+
'ITERATIONS': 0,
1359+
'MASK_LAYER': mask,
1360+
'NO_MASK': False,
1361+
'OUTPUT': outsource}, context, feedback),
1362+
['gdal_fillnodata.py',
1363+
'-md 10 -b 1 -mask ' +
1364+
mask +
1365+
' -of GTiff ' +
1366+
source + ' ' +
1367+
outsource])
1368+
1369+
# without mask value
1370+
self.assertEqual(
1371+
alg.getConsoleCommands({'INPUT': source,
1372+
'BAND': 1,
1373+
'DISTANCE': 10,
1374+
'ITERATIONS': 0,
1375+
'NO_MASK': False,
1376+
'OUTPUT': outsource}, context, feedback),
1377+
['gdal_fillnodata.py',
1378+
'-md 10 -b 1 ' +
1379+
'-of GTiff ' +
1380+
source + ' ' +
1381+
outsource])
1382+
1383+
# nomask true
1384+
self.assertEqual(
1385+
alg.getConsoleCommands({'INPUT': source,
1386+
'BAND': 1,
1387+
'DISTANCE': 10,
1388+
'ITERATIONS': 0,
1389+
'NO_MASK': True,
1390+
'OUTPUT': outsource}, context, feedback),
1391+
['gdal_fillnodata.py',
1392+
'-md 10 -b 1 -nomask ' +
1393+
'-of GTiff ' +
1394+
source + ' ' +
1395+
outsource])
1396+
13431397

13441398
class TestGdalOgrToPostGis(unittest.TestCase):
13451399

0 commit comments

Comments
 (0)