Revision 651cc3e2 test/py/ganeti.utils_unittest.py

b/test/py/ganeti.utils_unittest.py
369 369
                      some_keys, self.defaults)
370 370

  
371 371

  
372
class TestValidateDeviceNames(unittest.TestCase):
373
  def testEmpty(self):
374
    utils.ValidateDeviceNames("NIC", [])
375
    utils.ValidateDeviceNames("disk", [])
376

  
377
  def testNoName(self):
378
    nics = [{}, {}]
379
    utils.ValidateDeviceNames("NIC", nics)
380

  
381
  def testInvalidName(self):
382
    self.assertRaises(errors.OpPrereqError, utils.ValidateDeviceNames,
383
                      "disk", [{constants.IDISK_NAME: "42"}])
384
    self.assertRaises(errors.OpPrereqError, utils.ValidateDeviceNames,
385
                      "NIC", [{constants.INIC_NAME: "42"}])
386

  
387
  def testUsedName(self):
388
    disks = [{constants.IDISK_NAME: "name1"}, {constants.IDISK_NAME: "name1"}]
389
    self.assertRaises(errors.OpPrereqError, utils.ValidateDeviceNames,
390
                      "disk", disks)
391

  
392

  
372 393
if __name__ == "__main__":
373 394
  testutils.GanetiTestProgram()

Also available in: Unified diff