Revision 36bf7973 test/docs_unittest.py
b/test/docs_unittest.py | ||
---|---|---|
24 | 24 |
import unittest |
25 | 25 |
import re |
26 | 26 |
|
27 |
from ganeti import _autoconf |
|
27 | 28 |
from ganeti import utils |
28 | 29 |
from ganeti import cmdlib |
29 | 30 |
from ganeti.rapi import connector |
... | ... | |
115 | 116 |
utils.CommaJoin(undocumented))) |
116 | 117 |
|
117 | 118 |
|
119 |
class TestManpages(unittest.TestCase): |
|
120 |
"""Manpage tests""" |
|
121 |
|
|
122 |
@staticmethod |
|
123 |
def _ReadManFile(name): |
|
124 |
return utils.ReadFile("%s/man/%s.sgml" % |
|
125 |
(testutils.GetSourceDir(), name)) |
|
126 |
|
|
127 |
@staticmethod |
|
128 |
def _LoadScript(name): |
|
129 |
return utils.LoadModule("scripts/%s" % name) |
|
130 |
|
|
131 |
def test(self): |
|
132 |
for script in _autoconf.GNT_SCRIPTS: |
|
133 |
self._CheckManpage(script, |
|
134 |
self._ReadManFile(script), |
|
135 |
self._LoadScript(script).commands.keys()) |
|
136 |
|
|
137 |
def _CheckManpage(self, script, mantext, commands): |
|
138 |
missing = [] |
|
139 |
|
|
140 |
for cmd in commands: |
|
141 |
pattern = "<cmdsynopsis>\s*<command>%s</command>" % re.escape(cmd) |
|
142 |
if not re.findall(pattern, mantext, re.S): |
|
143 |
missing.append(cmd) |
|
144 |
|
|
145 |
self.failIf(missing, |
|
146 |
msg=("Manpage for '%s' missing documentation for %s" % |
|
147 |
(script, utils.CommaJoin(missing)))) |
|
148 |
|
|
149 |
|
|
118 | 150 |
if __name__ == "__main__": |
119 | 151 |
unittest.main() |
Also available in: Unified diff