make advanced params optional to keep algorithm API stable

This commit is contained in:
Alexander Bruy 2018-12-31 12:34:12 +02:00
parent 3d33b9f1e2
commit c64383702e
2 changed files with 12 additions and 2 deletions

View File

@ -83,12 +83,14 @@ class gdaladdo(GdalAlgorithm):
self.tr('Resampling method'),
options=[i[0] for i in self.methods],
allowMultiple=False,
defaultValue=0))
defaultValue=0,
optional=True))
params.append(QgsProcessingParameterEnum(self.FORMAT,
self.tr('Overviews format'),
options=self.formats,
allowMultiple=False,
defaultValue=0))
defaultValue=0,
optional=True))
for p in params:
p.setFlags(p.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
self.addParameter(p)

View File

@ -2440,6 +2440,14 @@ class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
['gdaladdo',
source + ' ' + '-r nearest 2 4 8 16 32 64'])
# without advanced params
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'LEVELS': '2 4 8 16',
'CLEAN': False}, context, feedback),
['gdaladdo',
source + ' ' + '-r nearest 2 4 8 16'])
class TestGdalOgrToPostGis(unittest.TestCase):