Browse Source

[213] Sort correctly even when no priority

Because it failed in real life.
Michal 'vorner' Vaner 13 years ago
parent
commit
7f1dcc956a

+ 3 - 1
src/lib/python/isc/bind10/component.py

@@ -403,7 +403,9 @@ class Configurator:
                 }))
         # Push the starts there sorted by priority
         plan.extend([command for (_, command) in sorted(plan_add,
-                                                        reverse=True)])
+                                                        reverse=True,
+                                                        key=lambda command:
+                                                            command[0])])
         return plan
 
     def running(self):

+ 9 - 0
src/lib/python/isc/bind10/tests/component_test.py

@@ -749,6 +749,15 @@ class ConfiguratorTest(BossUtils, unittest.TestCase):
         # It can't be stopped twice
         self.assertRaises(ValueError, configurator.shutdown)
 
+    def test_sort_no_prio(self):
+        """
+        There was a bug if there were two things with the same priority
+        (or without priority), it failed as it couldn't compare the dicts
+        there. This tests it doesn't crash.
+        """
+        configurator = Configurator(self)
+        configurator._build_plan({}, {"c1": {}, "c2": {}})
+
 if __name__ == '__main__':
     isc.log.init("bind10") # FIXME Should this be needed?
     isc.log.resetUnitTestRootLogger()