Fix TestDetermineKeyBits
authorHelga Velroyen <helgav@google.com>
Fri, 15 Jan 2016 10:30:27 +0000 (11:30 +0100)
committerHelga Velroyen <helgav@google.com>
Fri, 22 Jan 2016 09:38:58 +0000 (10:38 +0100)
The test never ran, because it did not inherit from a
test case class. This patch fixes that and all nits that
made the tests fail.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

test/py/ganeti.ssh_unittest.py

index 265adec..3510992 100755 (executable)
@@ -488,36 +488,37 @@ class TestGetUserFiles(testutils.GanetiTestCase):
     self.assertTrue(os.path.exists(self.priv_filename + suffix + ".pub"))
 
 
-class TestDetermineKeyBits():
+class TestDetermineKeyBits(testutils.GanetiTestCase):
   def testCompleteness(self):
-    self.assertEquals(constants.SSHK_ALL, ssh.SSH_KEY_VALID_BITS.keys())
+    self.assertEquals(constants.SSHK_ALL,
+                      frozenset(ssh.SSH_KEY_VALID_BITS.keys()))
 
   def testAdoptDefault(self):
-    self.assertEquals(2048, DetermineKeyBits("rsa", None, None, None))
-    self.assertEquals(1024, DetermineKeyBits("dsa", None, None, None))
+    self.assertEquals(2048, ssh.DetermineKeyBits("rsa", None, None, None))
+    self.assertEquals(1024, ssh.DetermineKeyBits("dsa", None, None, None))
 
   def testAdoptOldKeySize(self):
-    self.assertEquals(4098, DetermineKeyBits("rsa", None, "rsa", 4098))
-    self.assertEquals(2048, DetermineKeyBits("rsa", None, "dsa", 1024))
+    self.assertEquals(4098, ssh.DetermineKeyBits("rsa", None, "rsa", 4098))
+    self.assertEquals(2048, ssh.DetermineKeyBits("rsa", None, "dsa", 1024))
 
   def testDsaSpecificValues(self):
-    self.assertRaises(errors.OpPrereqError, DetermineKeyBits, "dsa", 2048,
+    self.assertRaises(errors.OpPrereqError, ssh.DetermineKeyBits, "dsa", 2048,
                       None, None)
-    self.assertRaises(errors.OpPrereqError, DetermineKeyBits, "dsa", 512,
+    self.assertRaises(errors.OpPrereqError, ssh.DetermineKeyBits, "dsa", 512,
                       None, None)
-    self.assertEquals(1024, DetermineKeyBits("dsa", None, None, None))
+    self.assertEquals(1024, ssh.DetermineKeyBits("dsa", None, None, None))
 
   def testEcdsaSpecificValues(self):
-    self.assertRaises(errors.OpPrereqError, DetermineKeyBits, "ecdsa", 2048,
+    self.assertRaises(errors.OpPrereqError, ssh.DetermineKeyBits, "ecdsa", 2048,
                       None, None)
     for b in [256, 384, 521]:
-      self.assertEquals(b, DetermineKeyBits("ecdsa", b, None, None))
+      self.assertEquals(b, ssh.DetermineKeyBits("ecdsa", b, None, None))
 
   def testRsaSpecificValues(self):
-    self.assertRaises(errors.OpPrereqError, DetermineKeyBits, "dsa", 766,
+    self.assertRaises(errors.OpPrereqError, ssh.DetermineKeyBits, "dsa", 766,
                       None, None)
     for b in [768, 769, 2048, 2049, 4096]:
-      self.assertEquals(b, DetermineKeyBits("rsa", b, None, None))
+      self.assertEquals(b, ssh.DetermineKeyBits("rsa", b, None, None))
 
 
 if __name__ == "__main__":