Revision bdfd7802 test/ganeti.opcodes_unittest.py

b/test/ganeti.opcodes_unittest.py
306 306
      self.assertFalse(check_norelative(i))
307 307

  
308 308

  
309
class TestResultChecks(unittest.TestCase):
310
  def testJobIdList(self):
311
    for i in [[], [(False, "error")], [(False, "")],
312
              [(True, 123), (True, "999")]]:
313
      self.assertTrue(opcodes.TJobIdList(i))
314

  
315
    for i in ["", [("x", 1)], [[], []], [[False, "", None], [True, 123]]]:
316
      self.assertFalse(opcodes.TJobIdList(i))
317

  
318
  def testJobIdListOnly(self):
319
    self.assertTrue(opcodes.TJobIdListOnly({
320
      constants.JOB_IDS_KEY: [],
321
      }))
322
    self.assertTrue(opcodes.TJobIdListOnly({
323
      constants.JOB_IDS_KEY: [(True, "9282")],
324
      }))
325

  
326
    self.assertFalse(opcodes.TJobIdListOnly({
327
      "x": None,
328
      }))
329
    self.assertFalse(opcodes.TJobIdListOnly({
330
      constants.JOB_IDS_KEY: [],
331
      "x": None,
332
      }))
333
    self.assertFalse(opcodes.TJobIdListOnly({
334
      constants.JOB_IDS_KEY: [("foo", "bar")],
335
      }))
336
    self.assertFalse(opcodes.TJobIdListOnly({
337
      constants.JOB_IDS_KEY: [("one", "two", "three")],
338
      }))
339

  
340

  
309 341
if __name__ == "__main__":
310 342
  testutils.GanetiTestProgram()

Also available in: Unified diff