Merge lp:~rvb/maas/api-doc-bug-1411363 into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 3464
Proposed branch: lp:~rvb/maas/api-doc-bug-1411363
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 33 lines (+16/-0)
1 file modified
src/maasserver/api/tests/test_doc.py (+16/-0)
To merge this branch: bzr merge lp:~rvb/maas/api-doc-bug-1411363
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+246683@code.launchpad.net

Commit message

Add a test to make sure the API documentation contains some of the text used in the docstrings of the API methods.

Description of the change

This is meant to catch bugs like bug 1411363 where the API documentation gets broken before the API doc gets deployed.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Cool. There may be some surprises when those particular doc strings are changed and this test fails, but I think it's all for a good cause.

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

> Cool. There may be some surprises when those particular doc strings are
> changed and this test fails, but I think it's all for a good cause.

Yeah, these failures will be easy to fix.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api/tests/test_doc.py'
2--- src/maasserver/api/tests/test_doc.py 2014-09-27 16:01:00 +0000
3+++ src/maasserver/api/tests/test_doc.py 2015-01-16 10:16:22 +0000
4@@ -33,6 +33,7 @@
5 generate_api_docs,
6 generate_power_types_doc,
7 )
8+from maasserver.api.doc_handler import render_api_docs
9 from maasserver.api.support import (
10 operation,
11 OperationsHandler,
12@@ -185,6 +186,21 @@
13 "%d handlers are missing an api_doc_section_name field." % len(
14 handlers_missing_section_name))
15
16+ def test_contains_documentation_from_handlers(self):
17+ # The documentation contains some of the text used in the docstrings
18+ # of the API's methods.
19+ # This test is meant to catch bugs like bug 1411363.
20+ doc = render_api_docs()
21+ doc_snippets = [
22+ # Doc for a method.
23+ "Manage custom commissioning scripts.",
24+ # Doc for a method parameter.
25+ "GET a FileStorage object as a json object.",
26+ # Doc for a method parameter (:param: doc).
27+ "Optional prefix used to filter out the returned files.",
28+ ]
29+ self.assertThat(doc, ContainsAll(doc_snippets))
30+
31
32 class ExampleHandler(OperationsHandler):
33 """An example handler."""