From: Zane Bitter Date: Fri, 17 May 2013 08:57:21 +0000 (+0200) Subject: Fix error in Dependencies representation X-Git-Tag: 2014.1~597^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=0f47986b659407058c26b4bef9c7441ecb5772c4;p=openstack-build%2Fheat-build.git Fix error in Dependencies representation This mostly only exists for debugging, but it's helpful if it can actually run. Change-Id: Ie29da5e7e58aed54aaaffa4df479fa0d96ce78fe --- diff --git a/heat/engine/dependencies.py b/heat/engine/dependencies.py index 1f900d4f..882158ee 100644 --- a/heat/engine/dependencies.py +++ b/heat/engine/dependencies.py @@ -62,16 +62,18 @@ class Dependencies(object): return self def __nonzero__(self): - '''Test if this node is a leaf (requires nothing)''' + ''' + Return True if this node is not a leaf (it requires other nodes) + ''' return bool(self.require) def stem(self): - '''Test if this node is a stem (required by nothing)''' + '''Return True if this node is a stem (required by nothing)''' return not bool(self.satisfy) def disjoint(self): - '''Test if this node is both a lead and a stem''' - return self and self.stem() + '''Return True if this node is both a leaf and a stem''' + return (not self) and self.stem() def __len__(self): '''Count the number of keys required by this node''' @@ -159,11 +161,12 @@ class Dependencies(object): else: for rqd in node: yield (rqr, rqd) - return (outgoing_edges(*item) for item in self.deps.iteritems()) + return itertools.chain.from_iterable(outgoing_edges(*item) + for item in self.deps.iteritems()) def __repr__(self): '''Return a string representation of the object''' - return 'Dependencies([%s])' % ', '.join(repr(e) for e in edges) + return 'Dependencies([%s])' % ', '.join(repr(e) for e in self._edges()) def _toposort(self, deps): '''Generate a topological sort of a dependency graph''' diff --git a/heat/tests/test_dependencies.py b/heat/tests/test_dependencies.py index ec2f546e..d04d44f1 100644 --- a/heat/tests/test_dependencies.py +++ b/heat/tests/test_dependencies.py @@ -48,6 +48,11 @@ class dependenciesTest(unittest.TestCase): '"%s" is not greater than "%s"' % (str(a), str(b))) self._dep_test(reversed, assertGreater, deps) + def test_repr(self): + dp = Dependencies([('1', None), ('2', '3'), ('2', '4')]) + s = "Dependencies([('1', None), ('2', '3'), ('2', '4')])" + self.assertEqual(repr(dp), s) + def test_single_node(self): d = Dependencies([('only', None)]) l = list(iter(d))