Merge branch 'stable-2.6'
[ganeti-local] / test / ganeti.opcodes_unittest.py
index 299ed4a..7e6cb6e 100755 (executable)
@@ -35,6 +35,16 @@ from ganeti import compat
 import testutils
 
 
+#: Unless an opcode is included in the following list it must have a result
+#: check of some sort
+MISSING_RESULT_CHECK = frozenset([
+  opcodes.OpTestAllocator,
+  opcodes.OpTestDelay,
+  opcodes.OpTestDummy,
+  opcodes.OpTestJqueue,
+  ])
+
+
 class TestOpcodes(unittest.TestCase):
   def test(self):
     self.assertRaises(ValueError, opcodes.OpCode.LoadOpCode, None)
@@ -49,7 +59,13 @@ class TestOpcodes(unittest.TestCase):
       self.assertEqual(cls.OP_ID, opcodes._NameToId(cls.__name__))
       self.assertFalse(compat.any(cls.OP_ID.startswith(prefix)
                                   for prefix in opcodes._SUMMARY_PREFIX.keys()))
-      self.assertTrue(cls.OP_RESULT is None or callable(cls.OP_RESULT))
+      if cls in MISSING_RESULT_CHECK:
+        self.assertTrue(cls.OP_RESULT is None,
+                        msg=("%s is listed to not have a result check" %
+                             cls.OP_ID))
+      else:
+        self.assertTrue(callable(cls.OP_RESULT),
+                        msg=("%s should have a result check" % cls.OP_ID))
 
       self.assertRaises(TypeError, cls, unsupported_parameter="some value")
 
@@ -381,7 +397,7 @@ class TestOpInstanceSetParams(unittest.TestCase):
     self.assertFalse(fn([[constants.DDM_ADD]]))
 
   def testNicModifications(self):
-    fn = opcodes.OpInstanceSetParams._TestNicModifications
+    fn = opcodes.OpInstanceSetParams.TestNicModifications
     self._GenericTests(fn)
 
     for param in constants.INIC_PARAMS:
@@ -389,7 +405,7 @@ class TestOpInstanceSetParams(unittest.TestCase):
       self.assertTrue(fn([[constants.DDM_ADD, {param: param}]]))
 
   def testDiskModifications(self):
-    fn = opcodes.OpInstanceSetParams._TestDiskModifications
+    fn = opcodes.OpInstanceSetParams.TestDiskModifications
     self._GenericTests(fn)
 
     for param in constants.IDISK_PARAMS: