Skip to content
Permalink
Browse files

Merge pull request #3742 from nirvn/processing_fix_hasdependencies

[processing] check for parent alg dependencies in hasDependencies()
  • Loading branch information
nyalldawson committed Nov 12, 2016
2 parents c180cf3 + be2223f commit 08231b8b14cbb5a25c04b8d3f317ce997a558888
@@ -360,6 +360,10 @@ def hasDependencies(self, name):
elif isinstance(value, ValueFromOutput):
if value.alg == name:
return True
if alg.name != name:
for dep in alg.dependencies:
if (dep == name):
return True
return False

def getDependsOnAlgorithms(self, name):
@@ -27,7 +27,11 @@

from qgis.testing import start_app, unittest

from processing.modeler.ModelerAlgorithm import (ModelerAlgorithm, ModelerParameter)
from processing.modeler.ModelerAlgorithm import (Algorithm,
ModelerAlgorithm,
ModelerParameter,
ModelerOutput,
ValueFromOutput)
from processing.modeler.ModelerParametersDialog import (ModelerParametersDialog)
from processing.core.parameters import (ParameterFile,
ParameterNumber,
@@ -66,6 +70,26 @@ def testModelerParametersDialogAvailableValuesOfType(self):
self.assertEqual(set(p.name for p in dlg.getAvailableValuesOfType([ParameterString, ParameterNumber, ParameterFile])),
set(['string', 'string2', 'number', 'file']))

def testModelerAlgorithmHasDependencies(self):
# test hasDependencies from ModelerAlgorithm

m = ModelerAlgorithm()

a = Algorithm("qgis:clip")
m.addAlgorithm(a)
a2 = Algorithm("qgis:clip")
m.addAlgorithm(a2)

# test parent algorithm dependency
self.assertEqual(m.hasDependencies('QGISCLIP_1'), False)
a2.dependencies = ['QGISCLIP_1']
self.assertEqual(m.hasDependencies('QGISCLIP_1'), True)

# test output algorithm dependency
a2.dependencies = []
a.outputs['OUTPUT'] = ModelerOutput('out')
a2.params['INPUT'] = ValueFromOutput('QGISCLIP_1', 'OUTPUT')
self.assertEqual(m.hasDependencies('QGISCLIP_1'), True)

if __name__ == '__main__':
unittest.main()

0 comments on commit 08231b8

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