root / test / ganeti.constants_unittest.py @ d1908b41
History | View | Annotate | Download (2.1 kB)
1 | eeb1d86a | Michael Hanselmann | #!/usr/bin/python
|
---|---|---|---|
2 | eeb1d86a | Michael Hanselmann | #
|
3 | eeb1d86a | Michael Hanselmann | |
4 | eeb1d86a | Michael Hanselmann | # Copyright (C) 2006, 2007, 2008 Google Inc.
|
5 | eeb1d86a | Michael Hanselmann | #
|
6 | eeb1d86a | Michael Hanselmann | # This program is free software; you can redistribute it and/or modify
|
7 | eeb1d86a | Michael Hanselmann | # it under the terms of the GNU General Public License as published by
|
8 | eeb1d86a | Michael Hanselmann | # the Free Software Foundation; either version 2 of the License, or
|
9 | eeb1d86a | Michael Hanselmann | # (at your option) any later version.
|
10 | eeb1d86a | Michael Hanselmann | #
|
11 | eeb1d86a | Michael Hanselmann | # This program is distributed in the hope that it will be useful, but
|
12 | eeb1d86a | Michael Hanselmann | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | eeb1d86a | Michael Hanselmann | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | eeb1d86a | Michael Hanselmann | # General Public License for more details.
|
15 | eeb1d86a | Michael Hanselmann | #
|
16 | eeb1d86a | Michael Hanselmann | # You should have received a copy of the GNU General Public License
|
17 | eeb1d86a | Michael Hanselmann | # along with this program; if not, write to the Free Software
|
18 | eeb1d86a | Michael Hanselmann | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | eeb1d86a | Michael Hanselmann | # 0.0510-1301, USA.
|
20 | eeb1d86a | Michael Hanselmann | |
21 | eeb1d86a | Michael Hanselmann | |
22 | eeb1d86a | Michael Hanselmann | """Script for unittesting the constants module"""
|
23 | eeb1d86a | Michael Hanselmann | |
24 | eeb1d86a | Michael Hanselmann | |
25 | eeb1d86a | Michael Hanselmann | import unittest |
26 | eeb1d86a | Michael Hanselmann | |
27 | eeb1d86a | Michael Hanselmann | from ganeti import constants |
28 | eeb1d86a | Michael Hanselmann | |
29 | eeb1d86a | Michael Hanselmann | |
30 | eeb1d86a | Michael Hanselmann | class TestConstants(unittest.TestCase): |
31 | eeb1d86a | Michael Hanselmann | """Constants tests"""
|
32 | eeb1d86a | Michael Hanselmann | |
33 | eeb1d86a | Michael Hanselmann | def testConfigVersion(self): |
34 | eeb1d86a | Michael Hanselmann | self.failUnless(constants.CONFIG_MAJOR >= 0 and |
35 | eeb1d86a | Michael Hanselmann | constants.CONFIG_MAJOR <= 99)
|
36 | eeb1d86a | Michael Hanselmann | self.failUnless(constants.CONFIG_MINOR >= 0 and |
37 | eeb1d86a | Michael Hanselmann | constants.CONFIG_MINOR <= 99)
|
38 | eeb1d86a | Michael Hanselmann | self.failUnless(constants.CONFIG_REVISION >= 0 and |
39 | eeb1d86a | Michael Hanselmann | constants.CONFIG_REVISION <= 9999)
|
40 | eeb1d86a | Michael Hanselmann | self.failUnless(constants.CONFIG_VERSION >= 0 and |
41 | eeb1d86a | Michael Hanselmann | constants.CONFIG_VERSION <= 99999999)
|
42 | eeb1d86a | Michael Hanselmann | |
43 | 1b45f4e5 | Michael Hanselmann | self.failUnless(constants.BuildVersion(0, 0, 0) == 0) |
44 | 1b45f4e5 | Michael Hanselmann | self.failUnless(constants.BuildVersion(10, 10, 1010) == 10101010) |
45 | 1b45f4e5 | Michael Hanselmann | self.failUnless(constants.BuildVersion(12, 34, 5678) == 12345678) |
46 | 1b45f4e5 | Michael Hanselmann | self.failUnless(constants.BuildVersion(99, 99, 9999) == 99999999) |
47 | 1b45f4e5 | Michael Hanselmann | |
48 | 1b45f4e5 | Michael Hanselmann | self.failUnless(constants.SplitVersion(00000000) == (0, 0, 0)) |
49 | 1b45f4e5 | Michael Hanselmann | self.failUnless(constants.SplitVersion(10101010) == (10, 10, 1010)) |
50 | 1b45f4e5 | Michael Hanselmann | self.failUnless(constants.SplitVersion(12345678) == (12, 34, 5678)) |
51 | 1b45f4e5 | Michael Hanselmann | self.failUnless(constants.SplitVersion(99999999) == (99, 99, 9999)) |
52 | 1b45f4e5 | Michael Hanselmann | self.failUnless(constants.SplitVersion(constants.CONFIG_VERSION) ==
|
53 | 1b45f4e5 | Michael Hanselmann | (constants.CONFIG_MAJOR, constants.CONFIG_MINOR, |
54 | 1b45f4e5 | Michael Hanselmann | constants.CONFIG_REVISION)) |
55 | 1b45f4e5 | Michael Hanselmann | |
56 | eeb1d86a | Michael Hanselmann | |
57 | eeb1d86a | Michael Hanselmann | if __name__ == '__main__': |
58 | eeb1d86a | Michael Hanselmann | unittest.main() |