Move bootstrap-related RPC to generated wrappers
[ganeti-local] / test / ganeti.utils.algo_unittest.py
index a0685a8..96b4ff5 100755 (executable)
@@ -218,6 +218,23 @@ class TestNiceSort(unittest.TestCase):
     self.assertEqual(keyfn.count, len(data),
                      msg="Key function was not called once per value")
 
+  def testNiceSortKey(self):
+    self.assertEqual(algo.NiceSortKey(""),
+                     ([None] * algo._SORTER_GROUPS) + [""])
+    self.assertEqual(algo.NiceSortKey("Hello World"),
+                     ["Hello World"] +
+                     ([None] * int(algo._SORTER_GROUPS - 1)) + [""])
+    self.assertEqual(algo.NiceSortKey("node1.net75.bld3.example.com"),
+                     ["node", 1, ".net", 75, ".bld", 3, ".example.com",
+                      None, ""])
+
+
+class TestInvertDict(unittest.TestCase):
+  def testInvertDict(self):
+    test_dict = { "foo": 1, "bar": 2, "baz": 5 }
+    self.assertEqual(algo.InvertDict(test_dict),
+                     { 1: "foo", 2: "bar", 5: "baz"})
+
 
 class TimeMock:
   def __init__(self, values):