Support having different templates for different releases

We want to adjust the template for Kilo, so rename template.rst to
$release-template.rst and update the tests.

Change-Id: Ia65bc72c14f51ff7fbf54af1ef69e9f37c9d58a9
This commit is contained in:
Joe Gordon 2014-09-30 11:33:16 -07:00
parent ac85aa2af6
commit 58b5738abd
2 changed files with 18 additions and 16 deletions

View File

@ -86,21 +86,23 @@ class TestTitles(testtools.TestCase):
def test_template(self):
with open('specs/template.rst') as f:
template = f.read()
spec = docutils.core.publish_doctree(template)
template_titles = self._get_titles(spec)
releases = [x.split('/')[1] for x in glob.glob('specs/*/')]
for release in releases:
with open("specs/%s-template.rst" % release) as f:
template = f.read()
spec = docutils.core.publish_doctree(template)
template_titles = self._get_titles(spec)
files = glob.glob('specs/*/*')
for filename in files:
self.assertTrue(filename.endswith(".rst"),
"spec's file must uses 'rst' extension.")
with open(filename) as f:
data = f.read()
files = glob.glob("specs/%s/*" % release)
for filename in files:
self.assertTrue(filename.endswith(".rst"),
"spec's file must uses 'rst' extension.")
with open(filename) as f:
data = f.read()
spec = docutils.core.publish_doctree(data)
titles = self._get_titles(spec)
self._check_titles(filename, template_titles, titles)
self._check_lines_wrapping(filename, data)
self._check_no_cr(filename, data)
self._check_trailing_spaces(filename, data)
spec = docutils.core.publish_doctree(data)
titles = self._get_titles(spec)
self._check_titles(filename, template_titles, titles)
self._check_lines_wrapping(filename, data)
self._check_no_cr(filename, data)
self._check_trailing_spaces(filename, data)