2013-11-27 11:19:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2013-06-27 11:52:36 +00:00
|
|
|
# Import python libs
|
2014-11-21 19:05:13 +00:00
|
|
|
from __future__ import absolute_import
|
2013-02-17 13:23:51 +00:00
|
|
|
import re
|
2013-06-27 11:52:36 +00:00
|
|
|
|
|
|
|
# Import Salt Testing libs
|
|
|
|
from salttesting.helpers import ensure_in_syspath
|
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
|
|
|
# Import salt libs
|
|
|
|
import integration
|
2012-05-05 14:09:23 +00:00
|
|
|
|
2014-11-22 11:10:17 +00:00
|
|
|
# Import 3rd-party libs
|
2014-11-23 01:44:50 +00:00
|
|
|
import salt.ext.six as six
|
2014-11-22 11:10:17 +00:00
|
|
|
|
2012-03-28 18:07:48 +00:00
|
|
|
|
|
|
|
class SysModuleTest(integration.ModuleCase):
|
|
|
|
'''
|
|
|
|
Validate the sys module
|
|
|
|
'''
|
2013-02-08 18:14:00 +00:00
|
|
|
def test_valid_docs(self):
|
|
|
|
'''
|
|
|
|
Make sure no functions are exposed that don't have valid docstrings
|
|
|
|
'''
|
|
|
|
docs = self.run_function('sys.doc')
|
2013-02-17 12:52:36 +00:00
|
|
|
nodoc = set()
|
|
|
|
noexample = set()
|
2013-06-18 22:38:42 +00:00
|
|
|
allow_failure = (
|
2013-08-15 01:29:31 +00:00
|
|
|
'cp.recv',
|
2016-07-14 23:34:02 +00:00
|
|
|
'libcloud_dns.get_driver',
|
2015-01-29 22:01:35 +00:00
|
|
|
'lxc.run_cmd',
|
2016-07-18 16:32:32 +00:00
|
|
|
'ipset.long_range',
|
2013-06-18 22:38:42 +00:00
|
|
|
'pkg.expand_repo_def',
|
|
|
|
'runtests_decorators.depends',
|
|
|
|
'runtests_decorators.depends_will_fallback',
|
|
|
|
'runtests_decorators.missing_depends',
|
2013-12-06 22:27:56 +00:00
|
|
|
'runtests_decorators.missing_depends_will_fallback',
|
2016-05-24 21:26:28 +00:00
|
|
|
'swift.head',
|
2016-06-02 22:30:36 +00:00
|
|
|
'glance.warn_until',
|
2014-01-17 04:40:22 +00:00
|
|
|
'yumpkg.expand_repo_def',
|
|
|
|
'yumpkg5.expand_repo_def',
|
2015-02-28 17:47:12 +00:00
|
|
|
'container_resource.run',
|
2015-03-03 16:40:52 +00:00
|
|
|
'nspawn.stop',
|
|
|
|
'nspawn.restart',
|
2015-06-06 13:47:52 +00:00
|
|
|
'lowpkg.bin_pkg_info',
|
2016-03-22 03:56:17 +00:00
|
|
|
'state.apply',
|
2016-07-28 18:58:23 +00:00
|
|
|
'cmd.win_runas',
|
2016-07-28 20:50:50 +00:00
|
|
|
'status.list2cmdline'
|
2013-12-06 22:27:56 +00:00
|
|
|
)
|
2013-06-18 22:38:42 +00:00
|
|
|
|
2013-02-08 18:14:00 +00:00
|
|
|
for fun in docs:
|
|
|
|
if fun.startswith('runtests_helpers'):
|
|
|
|
continue
|
2013-04-22 21:40:15 +00:00
|
|
|
if fun in allow_failure:
|
|
|
|
continue
|
2014-11-22 11:10:17 +00:00
|
|
|
if not isinstance(docs[fun], six.string_types):
|
2013-02-17 12:52:36 +00:00
|
|
|
nodoc.add(fun)
|
2013-08-15 01:17:39 +00:00
|
|
|
elif not re.search(r'([E|e]xample(?:s)?)+(?:.*)::?', docs[fun]):
|
2013-02-17 12:52:36 +00:00
|
|
|
noexample.add(fun)
|
2013-02-08 18:14:00 +00:00
|
|
|
|
2013-02-17 12:52:36 +00:00
|
|
|
if not nodoc and not noexample:
|
|
|
|
return
|
|
|
|
|
|
|
|
raise AssertionError(
|
2014-07-15 15:26:55 +00:00
|
|
|
'There are some functions which do not have a docstring or do not '
|
|
|
|
'have an example:\nNo docstring:\n{0}\nNo example:\n{1}\n'.format(
|
2013-02-17 12:52:36 +00:00
|
|
|
'\n'.join([' - {0}'.format(f) for f in sorted(nodoc)]),
|
|
|
|
'\n'.join([' - {0}'.format(f) for f in sorted(noexample)]),
|
|
|
|
)
|
|
|
|
)
|
2012-07-20 06:21:01 +00:00
|
|
|
|
2013-06-27 11:52:36 +00:00
|
|
|
|
2012-07-20 06:21:01 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(SysModuleTest)
|