diff --git a/requirements.txt b/requirements.txt index b31aa78..ff50de1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,6 @@ pbr>=0.6,<1.0 oslosphinx>=2.2.0.0a2 sphinx>=1.1.2,<1.2 yasfb>=0.5.1 +testrepository>=0.0.18 +testtools>=0.9.34 +flake8 diff --git a/setup.py b/setup.py index b476b74..70c2b3f 100755 --- a/setup.py +++ b/setup.py @@ -18,5 +18,5 @@ import setuptools setuptools.setup( - setup_requires=['pbr>=0.6,<1.0'], - pbr=True) \ No newline at end of file + setup_requires=['pbr'], + pbr=True) diff --git a/specs/kilo/approved/index.rst b/specs/kilo/approved/index.rst deleted file mode 100644 index b533640..0000000 --- a/specs/kilo/approved/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -======================== - Approved Specifications -======================== - -.. toctree:: - :glob: - :maxdepth: 2 - - * - diff --git a/specs/kilo/approved/define-a-wire-protocol.rst b/specs/kilo/define-a-wire-protocol.rst similarity index 100% rename from specs/kilo/approved/define-a-wire-protocol.rst rename to specs/kilo/define-a-wire-protocol.rst diff --git a/specs/kilo/approved/fifo-optional.rst b/specs/kilo/fifo-optional.rst similarity index 100% rename from specs/kilo/approved/fifo-optional.rst rename to specs/kilo/fifo-optional.rst diff --git a/specs/kilo/index.rst b/specs/kilo/index.rst index b93b36d..a559eaa 100644 --- a/specs/kilo/index.rst +++ b/specs/kilo/index.rst @@ -6,4 +6,4 @@ :glob: :maxdepth: 2 - approved/index + * diff --git a/specs/kilo/approved/notification-api.rst b/specs/kilo/notification-api.rst similarity index 100% rename from specs/kilo/approved/notification-api.rst rename to specs/kilo/notification-api.rst diff --git a/specs/kilo/approved/persistent-transport.rst b/specs/kilo/persistent-transport.rst similarity index 100% rename from specs/kilo/approved/persistent-transport.rst rename to specs/kilo/persistent-transport.rst diff --git a/specs/kilo/approved/storage-capabilities.rst b/specs/kilo/storage-capabilities.rst similarity index 100% rename from specs/kilo/approved/storage-capabilities.rst rename to specs/kilo/storage-capabilities.rst diff --git a/specs/liberty/finish-client-support-for-v1.1-features.rst b/specs/liberty/finish-client-support-for-v1.1-features.rst index 0d9f91a..9255847 100644 --- a/specs/liberty/finish-client-support-for-v1.1-features.rst +++ b/specs/liberty/finish-client-support-for-v1.1-features.rst @@ -40,6 +40,9 @@ v1.1,the proposed change is to add support for the following features: 3. Notifications +Alternatives +------------ + Implementation ============== diff --git a/specs/liberty/policy_support.rst b/specs/liberty/policy_support.rst index 85ce2ca..21e5451 100644 --- a/specs/liberty/policy_support.rst +++ b/specs/liberty/policy_support.rst @@ -125,23 +125,6 @@ Dependencies ============ * oslo.policy - -Testing -======= - -* Unit tests -* Manual testing - -Documentation Impact -==================== - -* Feature need to be documented -* Add ``policy.json`` example -* Add documentation and examples of how to tweak policy settings - -References -========== - * http://docs.openstack.org/developer/keystone/architecture.html#approach-to-authorization-policy * http://docs.openstack.org/developer/keystone/api/keystone.openstack.common.policy.html * http://docs.openstack.org/developer/keystone/configuration.html#keystone-api-protection-with-role-based-access-control-rbac diff --git a/specs/newton/subscription-confirmation-support.rst b/specs/newton/subscription-confirmation-support.rst index 39245ac..a724f9c 100644 --- a/specs/newton/subscription-confirmation-support.rst +++ b/specs/newton/subscription-confirmation-support.rst @@ -203,21 +203,4 @@ Work Items Dependencies ============ -None - -Testing -======= - -Both unit and Tempest tests need to be created to cover the code change. - - -Documentation Impact -==================== - -The Zaqar API documentation will need to be updated to reflect the REST -API changes. - -References -========== - _`Amazon SNS`: http://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_title.py b/tests/test_title.py new file mode 100644 index 0000000..b22787d --- /dev/null +++ b/tests/test_title.py @@ -0,0 +1,111 @@ +# 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 os +import re + +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, spec, titles): + self.assertTrue(len(titles) >= 4, + "Titles count in '%s' doesn't match expected" % spec) + problem = 'Problem description' + self.assertIn(problem, titles) + + proposed = 'Proposed change' + self.assertIn(proposed, titles) + self.assertIn('Alternatives', titles[proposed], spec) + + impl = 'Implementation' + self.assertIn(impl, titles) + self.assertIn('Assignee(s)', titles[impl]) + self.assertIn('Work Items', titles[impl]) + + deps = 'Dependencies' + self.assertIn(deps, titles) + + def _check_lines_wrapping(self, tpl, raw): + for i, line in enumerate(raw.split("\n")): + if "http://" in line or "https://" in line: + continue + self.assertTrue( + len(line) < 80, + msg="%s:%d: Line limited to a maximum of 79 characters." % + (tpl, i + 1)) + + def _check_no_cr(self, tpl, raw): + matches = re.findall('\r', raw) + self.assertEqual( + len(matches), 0, + "Found %s literal carriage returns in file %s" % + (len(matches), tpl)) + + def _check_trailing_spaces(self, tpl, raw): + for i, line in enumerate(raw.split("\n")): + trailing_spaces = re.findall(" +$", line) + msg = "Found trailing spaces on line %s of %s" % (i + 1, tpl) + self.assertEqual(len(trailing_spaces), 0, msg) + + def test_template(self): + # NOTE (e0ne): adding 'template.rst' to ignore dirs to exclude it from + # os.listdir output + ignored_dirs = {'template.rst', 'api',} + + files = ['specs/template.rst'] + + # NOTE (e0ne): We don't check specs in 'api' directory because + # they don't match template.rts. Uncomment code below it you want + # to test them. + # files.extend(glob.glob('specs/api/*/*')) + + releases = set(os.listdir('specs')) - ignored_dirs + for release in releases: + specs = glob.glob('specs/%s/*' % release) + files.extend(specs) + + for filename in files: + self.assertTrue(filename.endswith(".rst"), + "spec's file must use 'rst' extension.") + if filename.split('/')[-1] != 'index.rst': + with open(filename) as f: + data = f.read() + + spec = docutils.core.publish_doctree(data) + titles = self._get_titles(spec) + self._check_titles(filename, titles) + #self._check_lines_wrapping(filename, data) + self._check_no_cr(filename, data) + self._check_trailing_spaces(filename, data) diff --git a/tox.ini b/tox.ini index c354f60..9a66125 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 1.6 -envlist = docs +envlist = docs,py27,pep8 skipsdist = True [testenv] @@ -10,6 +10,7 @@ setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +commands = python setup.py testr --slowest --testr-args='{posargs}' [testenv:venv] commands = {posargs} @@ -22,4 +23,18 @@ deps = -r{toxinidir}/requirements.txt sphinxcontrib-spelling PyEnchant -commands = sphinx-build -b spelling doc/source doc/build/spelling \ No newline at end of file +commands = sphinx-build -b spelling doc/source doc/build/spelling + +[testenv:cover] +commands = python setup.py testr --coverage --testr-args='{posargs}' + +[testenv:pep8] +commands = flake8 + +[flake8] +# H803 skipped on purpose per list discussion. +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125 +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build