Skip to content

Commit

Permalink
[processing] consider destination params as outputs when defining scr…
Browse files Browse the repository at this point in the history
…ipts
  • Loading branch information
volaya authored and nyalldawson committed Feb 25, 2019
1 parent 519a30f commit 29b952d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/processing/algfactory.py
Expand Up @@ -211,7 +211,8 @@ def has_outputs(self):
"""
True if this alg wrapper has outputs defined.
"""
return bool(self._outputs)
dests = [p for p in self._inputs.values() if p.isDestination()]
return bool(self._outputs) or bool(dests)

@property
def has_inputs(self):
Expand Down
22 changes: 22 additions & 0 deletions tests/src/python/test_processing_alg_decorator.py
Expand Up @@ -37,6 +37,19 @@ def testalg(instance, parameters, context, feedback, inputs):
"""


def define_new_no_outputs_but_sink_instead(newid=1):
@alg(name=ARGNAME.format(newid), label=alg.tr("Test func"), group="unittest",
group_label=alg.tr("Test label"))
@alg.help(HELPSTRING.format(newid))
@alg.input(type=alg.SOURCE, name="INPUT", label="Input layer")
@alg.input(type=alg.DISTANCE, name="DISTANCE", label="Distance", default=30)
@alg.input(type=alg.SINK, name="SINK", label="Output layer")
def testalg(instance, parameters, context, feedback, inputs):
"""
Given a distance will split a line layer into segments of the distance
"""


def define_new_doc_string(newid=1):
@alg(name=ARGNAME.format(newid), label=alg.tr("Test func"), group="unittest",
group_label=alg.tr("Test label"))
Expand Down Expand Up @@ -75,6 +88,15 @@ def test_can_have_no_inputs(self):
define_new_no_inputs()


class AlgNoOutputsButSinkInstead(unittest.TestCase):

def setUp(self):
cleanup()

def test_can_have_no_outputs_if_there_is_destination(self):
define_new_no_outputs_but_sink_instead()


class AlgInstanceTests(unittest.TestCase):
"""
Tests to check the createInstance method will work as expected.
Expand Down

0 comments on commit 29b952d

Please sign in to comment.