root / test / py / ganeti.cmdlib.common_unittest.py @ cd3b4ff4
History | View | Annotate | Download (1.7 kB)
1 | 4e771a95 | Helga Velroyen | #!/usr/bin/python
|
---|---|---|---|
2 | 4e771a95 | Helga Velroyen | #
|
3 | 4e771a95 | Helga Velroyen | |
4 | 4e771a95 | Helga Velroyen | # Copyright (C) 2013 Google Inc.
|
5 | 4e771a95 | Helga Velroyen | #
|
6 | 4e771a95 | Helga Velroyen | # This program is free software; you can redistribute it and/or modify
|
7 | 4e771a95 | Helga Velroyen | # it under the terms of the GNU General Public License as published by
|
8 | 4e771a95 | Helga Velroyen | # the Free Software Foundation; either version 2 of the License, or
|
9 | 4e771a95 | Helga Velroyen | # (at your option) any later version.
|
10 | 4e771a95 | Helga Velroyen | #
|
11 | 4e771a95 | Helga Velroyen | # This program is distributed in the hope that it will be useful, but
|
12 | 4e771a95 | Helga Velroyen | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 4e771a95 | Helga Velroyen | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 4e771a95 | Helga Velroyen | # General Public License for more details.
|
15 | 4e771a95 | Helga Velroyen | #
|
16 | 4e771a95 | Helga Velroyen | # You should have received a copy of the GNU General Public License
|
17 | 4e771a95 | Helga Velroyen | # along with this program; if not, write to the Free Software
|
18 | 4e771a95 | Helga Velroyen | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | 4e771a95 | Helga Velroyen | # 02110-1301, USA.
|
20 | 4e771a95 | Helga Velroyen | |
21 | 4e771a95 | Helga Velroyen | |
22 | 4e771a95 | Helga Velroyen | """Script for unittesting the cmdlib module 'common'"""
|
23 | 4e771a95 | Helga Velroyen | |
24 | 4e771a95 | Helga Velroyen | |
25 | 4e771a95 | Helga Velroyen | import unittest |
26 | 4e771a95 | Helga Velroyen | |
27 | 4e771a95 | Helga Velroyen | from ganeti.cmdlib import common |
28 | 4e771a95 | Helga Velroyen | from ganeti import constants |
29 | 4e771a95 | Helga Velroyen | from ganeti import errors |
30 | 4e771a95 | Helga Velroyen | |
31 | 4e771a95 | Helga Velroyen | import testutils |
32 | 4e771a95 | Helga Velroyen | |
33 | 4e771a95 | Helga Velroyen | |
34 | 4e771a95 | Helga Velroyen | class TestCheckIpolicy(unittest.TestCase): |
35 | 4e771a95 | Helga Velroyen | |
36 | 4e771a95 | Helga Velroyen | def testAllTemplatesEnabled(self): |
37 | 4e771a95 | Helga Velroyen | allowed_disk_templates = [constants.DT_PLAIN] |
38 | 4e771a95 | Helga Velroyen | ipolicy = {constants.IPOLICY_DTS: allowed_disk_templates} |
39 | 4e771a95 | Helga Velroyen | enabled_disk_templates = [constants.DT_PLAIN, constants.DT_DRBD8] |
40 | 4e771a95 | Helga Velroyen | common.CheckIpolicyVsDiskTemplates( |
41 | 4e771a95 | Helga Velroyen | ipolicy, enabled_disk_templates) |
42 | 4e771a95 | Helga Velroyen | |
43 | 4e771a95 | Helga Velroyen | def testSomeTemplatesUnenabled(self): |
44 | 4e771a95 | Helga Velroyen | allowed_disk_templates = [constants.DT_PLAIN, constants.DT_DISKLESS] |
45 | 4e771a95 | Helga Velroyen | ipolicy = {constants.IPOLICY_DTS: allowed_disk_templates} |
46 | 4e771a95 | Helga Velroyen | enabled_disk_templates = [constants.DT_PLAIN, constants.DT_DRBD8] |
47 | 4e771a95 | Helga Velroyen | self.assertRaises(
|
48 | 4e771a95 | Helga Velroyen | errors.OpPrereqError, |
49 | 4e771a95 | Helga Velroyen | common.CheckIpolicyVsDiskTemplates, |
50 | 4e771a95 | Helga Velroyen | ipolicy, enabled_disk_templates) |
51 | 4e771a95 | Helga Velroyen | |
52 | 4e771a95 | Helga Velroyen | |
53 | 4e771a95 | Helga Velroyen | if __name__ == "__main__": |
54 | 4e771a95 | Helga Velroyen | testutils.GanetiTestProgram() |