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)
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")
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:
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: