Revision b342c9dd test/py/ganeti.objects_unittest.py

b/test/py/ganeti.objects_unittest.py
428 428
    self._AssertIPolicyIsFull(constants.IPOLICY_DEFAULTS)
429 429

  
430 430
  def testCheckISpecSyntax(self):
431
    default_stdspec = constants.IPOLICY_DEFAULTS[constants.ISPECS_STD]
431 432
    incomplete_ipolicies = [
432 433
      {
433 434
         constants.ISPECS_MINMAX: {},
434
         constants.ISPECS_STD: NotImplemented,
435
         constants.ISPECS_STD: default_stdspec,
435 436
         },
436 437
      {
437 438
        constants.ISPECS_MINMAX: {
438 439
          constants.ISPECS_MIN: NotImplemented,
439 440
          },
440
        constants.ISPECS_STD: NotImplemented,
441
        constants.ISPECS_STD: default_stdspec,
441 442
        },
442 443
      {
443 444
        constants.ISPECS_MINMAX: {
444 445
          constants.ISPECS_MAX: NotImplemented,
445 446
          },
446
        constants.ISPECS_STD: NotImplemented,
447
        constants.ISPECS_STD: default_stdspec,
447 448
        },
448 449
      {
449 450
        constants.ISPECS_MINMAX: {
......
488 489
      stdspec = {par: st}
489 490
      objects.InstancePolicy._CheckISpecParamSyntax(minmax, stdspec, par, True)
490 491
    bad_values = [
491
      (11, 11,  5),
492
      (40, 11, 11),
493
      (11, 80, 40),
494
      (11,  5, 40),
495
      (11,  5,  5),
496
      (40, 40, 11),
492
      (11, 11,  5, True),
493
      (40, 11, 11, True),
494
      (11, 80, 40, False),
495
      (11,  5, 40, False,),
496
      (11,  5,  5, True),
497
      (40, 40, 11, True),
497 498
      ]
498
    for (mn, st, mx) in bad_values:
499
    for (mn, st, mx, excp) in bad_values:
499 500
      minmax = {
500 501
        constants.ISPECS_MIN: {par: mn},
501 502
        constants.ISPECS_MAX: {par: mx},
502 503
        }
503 504
      stdspec = {par: st}
504
      self.assertRaises(errors.ConfigurationError,
505
                        objects.InstancePolicy._CheckISpecParamSyntax,
506
                        minmax, stdspec, par, True)
505
      if excp:
506
        self.assertRaises(errors.ConfigurationError,
507
                          objects.InstancePolicy._CheckISpecParamSyntax,
508
                          minmax, stdspec, par, True)
509
      else:
510
        ret = objects.InstancePolicy._CheckISpecParamSyntax(minmax, stdspec,
511
                                                            par, True)
512
        self.assertFalse(ret)
507 513

  
508 514
  def testCheckDiskTemplates(self):
509 515
    invalid = "this_is_not_a_good_template"

Also available in: Unified diff