Merge "Check atom doesn't provide and return same values"

This commit is contained in:
Jenkins
2014-02-19 20:52:24 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 21 deletions

View File

@@ -19,6 +19,7 @@ import logging
import six
from taskflow import exceptions
from taskflow.utils import misc
from taskflow.utils import reflection
@@ -129,6 +130,12 @@ class Atom(object):
auto_extract=True):
self.rebind = _build_arg_mapping(self.name, requires, rebind,
executor, auto_extract)
out_of_order = self.provides.intersection(self.requires)
if out_of_order:
raise exceptions.InvariantViolation(
"Atom %(item)s provides %(oo)s that are required "
"by this atom"
% dict(item=self.name, oo=sorted(out_of_order)))
@property
def name(self):

View File

@@ -107,13 +107,6 @@ class FlowDependenciesTest(test.TestCase):
self.assertEqual(flow.requires, set(['a', 'b', 'c', 'z']))
self.assertEqual(flow.provides, set(['x', 'y', 'q', 'i', 'j', 'k']))
def test_linear_flow_self_requires(self):
flow = lf.Flow('lf')
self.assertRaises(exceptions.InvariantViolation,
flow.add,
utils.TaskNoRequiresNoReturns(rebind=['x'],
provides='x'))
def test_linear_flow_provides_same_values(self):
flow = lf.Flow('lf').add(utils.TaskOneReturn(provides='x'))
self.assertRaises(exceptions.DependencyFailure,
@@ -134,13 +127,6 @@ class FlowDependenciesTest(test.TestCase):
self.assertEqual(flow.requires, set())
self.assertEqual(flow.provides, set())
def test_unordered_flow_self_requires(self):
flow = uf.Flow('uf')
self.assertRaises(exceptions.InvariantViolation,
flow.add,
utils.TaskNoRequiresNoReturns(rebind=['x'],
provides='x'))
def test_unordered_flow_requires_values(self):
flow = uf.Flow('uf').add(
utils.TaskOneArg('task1'),
@@ -234,13 +220,6 @@ class FlowDependenciesTest(test.TestCase):
self.assertEqual(flow.requires, set())
self.assertEqual(flow.provides, set())
def test_graph_flow_self_requires(self):
flow = gf.Flow('g-1-req-error')
self.assertRaisesRegexp(exceptions.DependencyFailure, '^No path',
flow.add,
utils.TaskOneArgOneReturn(requires=['a'],
provides='a'))
def test_graph_flow_requires_values(self):
flow = gf.Flow('gf').add(
utils.TaskOneArg('task1'),
@@ -296,3 +275,9 @@ class FlowDependenciesTest(test.TestCase):
requires=['c']),
utils.TaskOneArgOneReturn(provides='c',
requires=['a']))
def test_task_requires_and_provides_same_values(self):
self.assertRaises(exceptions.InvariantViolation,
utils.TaskOneArgOneReturn,
requires='a',
provides='a')