Revision 5fa3d337 test/ganeti.opcodes_unittest.py

b/test/ganeti.opcodes_unittest.py
35 35
import testutils
36 36

  
37 37

  
38
#: Unless an opcode is included in the following list it must have a result
39
#: check of some sort
40
MISSING_RESULT_CHECK = frozenset([
41
  opcodes.OpBackupExport,
42
  opcodes.OpBackupQuery,
43
  opcodes.OpBackupRemove,
44
  opcodes.OpClusterQuery,
45
  opcodes.OpGroupQuery,
46
  opcodes.OpInstanceQuery,
47
  opcodes.OpInstanceQueryData,
48
  opcodes.OpNodeQuery,
49
  opcodes.OpNodeQueryStorage,
50
  opcodes.OpOsDiagnose,
51
  opcodes.OpQuery,
52
  opcodes.OpQueryFields,
53
  opcodes.OpTagsDel,
54
  opcodes.OpTagsGet,
55
  opcodes.OpTagsSearch,
56
  opcodes.OpTagsSet,
57
  opcodes.OpTestAllocator,
58
  opcodes.OpTestDelay,
59
  opcodes.OpTestDummy,
60
  opcodes.OpTestJqueue,
61
  ])
62

  
63

  
38 64
class TestOpcodes(unittest.TestCase):
39 65
  def test(self):
40 66
    self.assertRaises(ValueError, opcodes.OpCode.LoadOpCode, None)
......
49 75
      self.assertEqual(cls.OP_ID, opcodes._NameToId(cls.__name__))
50 76
      self.assertFalse(compat.any(cls.OP_ID.startswith(prefix)
51 77
                                  for prefix in opcodes._SUMMARY_PREFIX.keys()))
52
      self.assertTrue(cls.OP_RESULT is None or callable(cls.OP_RESULT))
78
      if cls in MISSING_RESULT_CHECK:
79
        self.assertTrue(cls.OP_RESULT is None,
80
                        msg=("%s is listed to not have a result check" %
81
                             cls.OP_ID))
82
      else:
83
        self.assertTrue(callable(cls.OP_RESULT),
84
                        msg=("%s should have a result check" % cls.OP_ID))
53 85

  
54 86
      self.assertRaises(TypeError, cls, unsupported_parameter="some value")
55 87

  

Also available in: Unified diff