Factor data out of _check_titles
The straight-line implementation style of this test method allows inconsistencies in checking to creep in. Switch to a data-driven approach. Change-Id: I8cd2be14f4338413854042031cf41da534c11dcb
This commit is contained in:
parent
e53f94060c
commit
98106401e1
|
@ -16,6 +16,27 @@ import docutils.core
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
|
||||||
|
TITLES = {
|
||||||
|
'Problem description': [],
|
||||||
|
'Proposed change': [
|
||||||
|
'Alternatives',
|
||||||
|
'Security impact',
|
||||||
|
'Other end user impact',
|
||||||
|
'Performance Impact',
|
||||||
|
'Other deployer impact',
|
||||||
|
'Developer impact',
|
||||||
|
],
|
||||||
|
'Implementation': [
|
||||||
|
'Assignee(s)',
|
||||||
|
'Work Items',
|
||||||
|
],
|
||||||
|
'Dependencies': [],
|
||||||
|
'Testing': [],
|
||||||
|
'Documentation Impact': [],
|
||||||
|
'References': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TestTitles(testtools.TestCase):
|
class TestTitles(testtools.TestCase):
|
||||||
def _get_title(self, section_tree):
|
def _get_title(self, section_tree):
|
||||||
section = {
|
section = {
|
||||||
|
@ -25,6 +46,7 @@ class TestTitles(testtools.TestCase):
|
||||||
if node.tagname == 'title':
|
if node.tagname == 'title':
|
||||||
section['name'] = node.rawsource
|
section['name'] = node.rawsource
|
||||||
elif node.tagname == 'section':
|
elif node.tagname == 'section':
|
||||||
|
# Note subsection subtitles are thrown away
|
||||||
subsection = self._get_title(node)
|
subsection = self._get_title(node)
|
||||||
section['subtitles'].append(subsection['name'])
|
section['subtitles'].append(subsection['name'])
|
||||||
return section
|
return section
|
||||||
|
@ -38,43 +60,7 @@ class TestTitles(testtools.TestCase):
|
||||||
return titles
|
return titles
|
||||||
|
|
||||||
def _check_titles(self, titles):
|
def _check_titles(self, titles):
|
||||||
self.assertEqual(7, len(titles))
|
self.assertEqual(TITLES, titles)
|
||||||
|
|
||||||
problem = 'Problem description'
|
|
||||||
self.assertIn(problem, titles)
|
|
||||||
self.assertEqual(0, len(titles[problem]))
|
|
||||||
|
|
||||||
proposed = 'Proposed change'
|
|
||||||
self.assertIn(proposed, titles)
|
|
||||||
self.assertEqual(6, len(titles[proposed]))
|
|
||||||
self.assertIn('Alternatives', titles[proposed])
|
|
||||||
self.assertIn('Security 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):
|
def test_template(self):
|
||||||
files = ['specs/template.rst'] + glob.glob('specs/*/*')
|
files = ['specs/template.rst'] + glob.glob('specs/*/*')
|
||||||
|
|
Loading…
Reference in New Issue