Revision b8d51bb2

b/lib/constants.py
1703 1703
HTOOLS = _autoconf.HTOOLS
1704 1704
# The hail iallocator
1705 1705
IALLOC_HAIL = "hail"
1706

  
1707
# Do not re-export imported modules
1708
del re, _vcsversion, _autoconf
b/test/ganeti.constants_unittest.py
24 24

  
25 25
import unittest
26 26
import re
27
import itertools
27 28

  
28 29
from ganeti import constants
29 30
from ganeti import locking
31
from ganeti import utils
30 32

  
31 33
import testutils
32 34

  
......
78 80
    self.failUnless(constants.OP_PRIO_HIGH > constants.OP_PRIO_HIGHEST)
79 81

  
80 82

  
83
class TestExportedNames(unittest.TestCase):
84
  _VALID_NAME_RE = re.compile(r"^[A-Z][A-Z0-9_]+$")
85
  _BUILTIN_NAME_RE = re.compile(r"^__\w+__$")
86
  _EXCEPTIONS = frozenset([
87
    "SplitVersion",
88
    "BuildVersion",
89
    ])
90

  
91
  def test(self):
92
    wrong = \
93
      set(itertools.ifilterfalse(self._BUILTIN_NAME_RE.match,
94
            itertools.ifilterfalse(self._VALID_NAME_RE.match,
95
                                   dir(constants))))
96
    wrong -= self._EXCEPTIONS
97
    self.assertFalse(wrong,
98
                     msg=("Invalid names exported from constants module: %s" %
99
                          utils.CommaJoin(sorted(wrong))))
100

  
101

  
81 102
class TestParameterNames(unittest.TestCase):
82 103
  """HV/BE parameter tests"""
83 104
  VALID_NAME = re.compile("^[a-zA-Z_][a-zA-Z0-9_]*$")

Also available in: Unified diff