]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fix error in Dependencies representation
authorZane Bitter <zbitter@redhat.com>
Fri, 17 May 2013 08:57:21 +0000 (10:57 +0200)
committerMonty Taylor <mordred@inaugust.com>
Fri, 17 May 2013 15:14:10 +0000 (08:14 -0700)
This mostly only exists for debugging, but it's helpful if it can actually
run.

Change-Id: Ie29da5e7e58aed54aaaffa4df479fa0d96ce78fe

heat/engine/dependencies.py
heat/tests/test_dependencies.py

index 1f900d4f89f3b7e73a38e317a2c8d9b05127aa5a..882158ee76365f59d80139243e0edc51421b1200 100644 (file)
@@ -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'''
index ec2f546e1c38860427bded5e6b990fe00044a248..d04d44f11341e8c22439ddedc15ded0e81c4e417 100644 (file)
@@ -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))