Revision 3882937a test/ganeti.rapi.rlib2_unittest.py

b/test/ganeti.rapi.rlib2_unittest.py
295 295
      self.assert_(op.name_check)
296 296

  
297 297

  
298
class TestParseModifyInstanceRequest(testutils.GanetiTestCase):
299
  def setUp(self):
300
    testutils.GanetiTestCase.setUp(self)
301

  
302
    self.Parse = rlib2._ParseModifyInstanceRequest
303

  
304
  def test(self):
305
    name = "instush8gah"
306

  
307
    test_disks = [
308
      [],
309
      [(1, { constants.IDISK_MODE: constants.DISK_RDWR, })],
310
      ]
311

  
312
    for osparams in [{}, { "some": "value", "other": "Hello World", }]:
313
      for hvparams in [{}, { constants.HV_KERNEL_PATH: "/some/kernel", }]:
314
        for beparams in [{}, { constants.BE_MEMORY: 128, }]:
315
          for force in [False, True]:
316
            for nics in [[], [(0, { constants.INIC_IP: "192.0.2.1", })]]:
317
              for disks in test_disks:
318
                for disk_template in constants.DISK_TEMPLATES:
319
                  data = {
320
                    "osparams": osparams,
321
                    "hvparams": hvparams,
322
                    "beparams": beparams,
323
                    "nics": nics,
324
                    "disks": disks,
325
                    "force": force,
326
                    "disk_template": disk_template,
327
                    }
328

  
329
                  op = self.Parse(name, data)
330
                  self.assert_(isinstance(op, opcodes.OpSetInstanceParams))
331
                  self.assertEqual(op.instance_name, name)
332
                  self.assertEqual(op.hvparams, hvparams)
333
                  self.assertEqual(op.beparams, beparams)
334
                  self.assertEqual(op.osparams, osparams)
335
                  self.assertEqual(op.force, force)
336
                  self.assertEqual(op.nics, nics)
337
                  self.assertEqual(op.disks, disks)
338
                  self.assertEqual(op.disk_template, disk_template)
339
                  self.assert_(op.remote_node is None)
340
                  self.assert_(op.os_name is None)
341
                  self.assertFalse(op.force_variant)
342

  
343
  def testDefaults(self):
344
    name = "instir8aish31"
345

  
346
    op = self.Parse(name, {})
347
    self.assert_(isinstance(op, opcodes.OpSetInstanceParams))
348
    self.assertEqual(op.instance_name, name)
349
    self.assertEqual(op.hvparams, {})
350
    self.assertEqual(op.beparams, {})
351
    self.assertEqual(op.osparams, {})
352
    self.assertFalse(op.force)
353
    self.assertEqual(op.nics, [])
354
    self.assertEqual(op.disks, [])
355
    self.assert_(op.disk_template is None)
356
    self.assert_(op.remote_node is None)
357
    self.assert_(op.os_name is None)
358
    self.assertFalse(op.force_variant)
359

  
360

  
298 361
if __name__ == '__main__':
299 362
  testutils.GanetiTestProgram()

Also available in: Unified diff