Add unit test to make sure all sections are present
Add a unit test that will check to make sure all top-level headings are present. This could be further improved to check for sub-headings, too. Co-authored-by: Russell Bryant <rbryant@redhat.com> Change-Id: I1c15282e166fb3fe2e60fcf063a6cd822a3411ff
This commit is contained in:
parent
525c1121ec
commit
8820c3805c
|
@ -0,0 +1,4 @@
|
||||||
|
[DEFAULT]
|
||||||
|
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=60 ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
|
||||||
|
test_id_option=--load-list $IDFILE
|
||||||
|
test_list_option=--list
|
|
@ -0,0 +1,51 @@
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import glob
|
||||||
|
|
||||||
|
import docutils.core
|
||||||
|
import testtools
|
||||||
|
|
||||||
|
|
||||||
|
class TestTitles(testtools.TestCase):
|
||||||
|
@staticmethod
|
||||||
|
def _get_title(section):
|
||||||
|
for node in section:
|
||||||
|
if node.tagname == 'title':
|
||||||
|
return node.rawsource
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_titles(spec):
|
||||||
|
titles = []
|
||||||
|
for node in spec:
|
||||||
|
if node.tagname == 'section':
|
||||||
|
titles.append(TestTitles._get_title(node))
|
||||||
|
return titles
|
||||||
|
|
||||||
|
def _check_titles(self, titles):
|
||||||
|
self.assertEqual(7, len(titles))
|
||||||
|
self.assertIn('Problem description', titles)
|
||||||
|
self.assertIn('Proposed change', titles)
|
||||||
|
self.assertIn('Implementation', titles)
|
||||||
|
self.assertIn('Dependencies', titles)
|
||||||
|
self.assertIn('Testing', titles)
|
||||||
|
self.assertIn('Documentation Impact', titles)
|
||||||
|
self.assertIn('References', titles)
|
||||||
|
|
||||||
|
def test_template(self):
|
||||||
|
files = ['specs/template.rst'] + glob.glob('specs/*/*.rst')
|
||||||
|
for filename in files:
|
||||||
|
with open(filename) as f:
|
||||||
|
data = f.read()
|
||||||
|
spec = docutils.core.publish_doctree(data)
|
||||||
|
titles = self._get_titles(spec)
|
||||||
|
self._check_titles(titles)
|
1
tox.ini
1
tox.ini
|
@ -8,6 +8,7 @@ usedevelop = True
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
install_command = pip install -U {opts} {packages}
|
install_command = pip install -U {opts} {packages}
|
||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
|
commands = python setup.py testr --slowest --testr-args='{posargs}'
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
Loading…
Reference in New Issue