ansible/test/runner/lib/sanity/sanity_docs.py
Matt Clay 79eca9c8fb
Initial ansible-test support for collections. (#59197)
* Initial ansible-test support for collections.
* Include cloud config in delegation payload.
* Add missing types import and fix `t` shadowing.
* Fix plugin traceback when config_path not set.
* Fix encoding issues.
* Remove unused imports.
* More encoding fixes.
* Handle delegation outside exception handler.
* Inject ssh keys only if not already in place.
* More defensive approach to getting remote pwd.
* Add missing string format var.
* Correct PowerShell require regex.
* Rename `is_install` and `INSTALL_ROOT`.
2019-07-22 19:24:48 -07:00

52 lines
1.4 KiB
Python

"""Sanity test for documentation of sanity tests."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
from lib.sanity import (
SanitySingleVersion,
SanityMessage,
SanityFailure,
SanitySuccess,
sanity_get_tests,
)
from lib.config import (
SanityConfig,
)
from lib.data import (
data_context,
)
class SanityDocsTest(SanitySingleVersion):
"""Sanity test for documentation of sanity tests."""
ansible_only = True
# noinspection PyUnusedLocal
def test(self, args, targets): # pylint: disable=locally-disabled, unused-argument
"""
:type args: SanityConfig
:type targets: SanityTargets
:rtype: TestResult
"""
sanity_dir = 'docs/docsite/rst/dev_guide/testing/sanity'
sanity_docs = set(part[0] for part in (os.path.splitext(os.path.basename(path)) for path in data_context().content.get_files(sanity_dir))
if part[1] == '.rst')
sanity_tests = set(sanity_test.name for sanity_test in sanity_get_tests())
missing = sanity_tests - sanity_docs
results = []
results += [SanityMessage(
message='missing docs for ansible-test sanity --test %s' % r,
path=os.path.join(sanity_dir, '%s.rst' % r),
) for r in sorted(missing)]
if results:
return SanityFailure(self.name, messages=results)
return SanitySuccess(self.name)