Revision 0c2e59ac test/ganeti.cmdlib_unittest.py
b/test/ganeti.cmdlib_unittest.py | ||
---|---|---|
1 | 1 |
#!/usr/bin/python |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2008, 2011 Google Inc. |
|
4 |
# Copyright (C) 2008, 2011, 2012 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
586 | 586 |
} |
587 | 587 |
|
588 | 588 |
def testNoneValue(self): |
589 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_MEM_SIZE, |
|
589 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_MEM_SIZE, None,
|
|
590 | 590 |
self.ipolicy, None) is None) |
591 | 591 |
|
592 | 592 |
def testAutoValue(self): |
593 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_MEM_SIZE, |
|
593 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_MEM_SIZE, None,
|
|
594 | 594 |
self.ipolicy, |
595 | 595 |
constants.VALUE_AUTO) is None) |
596 | 596 |
|
597 | 597 |
def testNotDefined(self): |
598 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_NIC_COUNT, |
|
598 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_NIC_COUNT, None,
|
|
599 | 599 |
self.ipolicy, 3) is None) |
600 | 600 |
|
601 | 601 |
def testNoMinDefined(self): |
602 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_DISK_SIZE, |
|
602 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_DISK_SIZE, None,
|
|
603 | 603 |
self.ipolicy, 128) is None) |
604 | 604 |
|
605 | 605 |
def testNoMaxDefined(self): |
606 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_DISK_COUNT, |
|
606 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(constants.ISPEC_DISK_COUNT, None,
|
|
607 | 607 |
self.ipolicy, 16) is None) |
608 | 608 |
|
609 | 609 |
def testOutOfRange(self): |
... | ... | |
613 | 613 |
(constants.ISPEC_DISK_COUNT, 0)): |
614 | 614 |
min_v = self.ipolicy[constants.ISPECS_MIN].get(name, val) |
615 | 615 |
max_v = self.ipolicy[constants.ISPECS_MAX].get(name, val) |
616 |
self.assertEqual(cmdlib._ComputeMinMaxSpec(name, self.ipolicy, val), |
|
616 |
self.assertEqual(cmdlib._ComputeMinMaxSpec(name, None, |
|
617 |
self.ipolicy, val), |
|
617 | 618 |
"%s value %s is not in range [%s, %s]" % |
618 | 619 |
(name, val,min_v, max_v)) |
620 |
self.assertEqual(cmdlib._ComputeMinMaxSpec(name, "1", |
|
621 |
self.ipolicy, val), |
|
622 |
"%s/1 value %s is not in range [%s, %s]" % |
|
623 |
(name, val,min_v, max_v)) |
|
619 | 624 |
|
620 | 625 |
def test(self): |
621 | 626 |
for (name, val) in ((constants.ISPEC_MEM_SIZE, 256), |
... | ... | |
625 | 630 |
(constants.ISPEC_DISK_SIZE, 0), |
626 | 631 |
(constants.ISPEC_DISK_COUNT, 1), |
627 | 632 |
(constants.ISPEC_DISK_COUNT, 5)): |
628 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(name, self.ipolicy, val) |
|
633 |
self.assertTrue(cmdlib._ComputeMinMaxSpec(name, None, self.ipolicy, val)
|
|
629 | 634 |
is None) |
630 | 635 |
|
631 | 636 |
|
Also available in: Unified diff