Skip to content
Permalink
Browse files

[processing] consider destination params as outputs when defining scr…

…ipts
  • Loading branch information
volaya authored and nyalldawson committed Feb 25, 2019
1 parent 519a30f commit 29b952d90cc904d08174fef3ea0eac0cf766c195
Showing with 24 additions and 1 deletion.
  1. +2 −1 python/processing/algfactory.py
  2. +22 −0 tests/src/python/test_processing_alg_decorator.py
@@ -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):
@@ -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"))
@@ -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.

0 comments on commit 29b952d

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