diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 000000000..1641f86e3 --- /dev/null +++ b/.testr.conf @@ -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 diff --git a/requirements.txt b/requirements.txt index 340d2ab33..bdd3e93ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ docutils==0.9.1 oslosphinx pbr>=0.6,<1.0 sphinx>=1.1.2,<1.2 +testrepository>=0.0.18 +testtools>=0.9.34 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test_titles.py b/tests/test_titles.py new file mode 100644 index 000000000..5596d0aa0 --- /dev/null +++ b/tests/test_titles.py @@ -0,0 +1,89 @@ +# 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): + def _get_title(self, section_tree): + section = { + 'subtitles': [], + } + for node in section_tree: + if node.tagname == 'title': + section['name'] = node.rawsource + elif node.tagname == 'section': + subsection = self._get_title(node) + section['subtitles'].append(subsection['name']) + return section + + def _get_titles(self, spec): + titles = {} + for node in spec: + if node.tagname == 'section': + section = self._get_title(node) + titles[section['name']] = section['subtitles'] + return titles + + def _check_titles(self, titles): + self.assertEqual(7, len(titles)) + + problem = 'Problem description' + self.assertIn(problem, titles) + self.assertEqual(0, len(titles[problem])) + + proposed = 'Proposed change' + self.assertIn(proposed, titles) + self.assertEqual(9, len(titles[proposed])) + self.assertIn('Alternatives', titles[proposed]) + self.assertIn('Data model impact', titles[proposed]) + self.assertIn('REST API impact', titles[proposed]) + self.assertIn('Security impact', titles[proposed]) + self.assertIn('Notifications impact', titles[proposed]) + self.assertIn('Other end user impact', titles[proposed]) + self.assertIn('Performance Impact', titles[proposed]) + self.assertIn('Other deployer impact', titles[proposed]) + self.assertIn('Developer impact', titles[proposed]) + + impl = 'Implementation' + self.assertIn(impl, titles) + self.assertEqual(2, len(titles[impl])) + self.assertIn('Assignee(s)', titles[impl]) + self.assertIn('Work Items', titles[impl]) + + deps = 'Dependencies' + self.assertIn(deps, titles) + self.assertEqual(0, len(titles[deps])) + + testing = 'Testing' + self.assertIn(testing, titles) + self.assertEqual(0, len(titles[testing])) + + docs = 'Documentation Impact' + self.assertIn(docs, titles) + self.assertEqual(0, len(titles[docs])) + + refs = 'References' + self.assertIn(refs, titles) + self.assertEqual(0, len(titles[refs])) + + 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) diff --git a/tox.ini b/tox.ini index aacefbec6..b92724b3d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 1.6 -envlist = docs +envlist = docs,py27 skipsdist = True [testenv] @@ -8,6 +8,7 @@ usedevelop = True setenv = VIRTUAL_ENV={envdir} install_command = pip install -U {opts} {packages} deps = -r{toxinidir}/requirements.txt +commands = python setup.py testr --slowest --testr-args='{posargs}' [testenv:venv] commands = {posargs}