Commit b58a4d16 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Fix typos in RAPI docstrings, add unittest



This patch fixes a number of typos and standardizes RAPI resource
docstrings. A unittest is added.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent acd19189
......@@ -134,7 +134,9 @@ def _getResources(id_):
class R_2(baserlib.R_Generic):
""" /2 resource, the root of the version 2 API.
"""/2 resource.
This is the root of the version 2 API.
"""
@staticmethod
......
......@@ -122,7 +122,7 @@ class R_version(baserlib.R_Generic):
class R_2_info(baserlib.R_Generic):
"""Cluster info.
"""/2/info resource.
"""
@staticmethod
......@@ -329,7 +329,7 @@ class R_2_nodes(baserlib.R_Generic):
class R_2_nodes_name(baserlib.R_Generic):
"""/2/nodes/[node_name] resources.
"""/2/nodes/[node_name] resource.
"""
def GET(self):
......@@ -470,7 +470,7 @@ class R_2_nodes_name_migrate(baserlib.R_Generic):
class R_2_nodes_name_storage(baserlib.R_Generic):
"""/2/nodes/[node_name]/storage ressource.
"""/2/nodes/[node_name]/storage resource.
"""
# LUQueryNodeStorage acquires locks, hence restricting access to GET
......@@ -496,7 +496,7 @@ class R_2_nodes_name_storage(baserlib.R_Generic):
class R_2_nodes_name_storage_modify(baserlib.R_Generic):
"""/2/nodes/[node_name]/storage/modify ressource.
"""/2/nodes/[node_name]/storage/modify resource.
"""
def PUT(self):
......@@ -526,7 +526,7 @@ class R_2_nodes_name_storage_modify(baserlib.R_Generic):
class R_2_nodes_name_storage_repair(baserlib.R_Generic):
"""/2/nodes/[node_name]/storage/repair ressource.
"""/2/nodes/[node_name]/storage/repair resource.
"""
def PUT(self):
......@@ -594,7 +594,7 @@ class R_2_groups(baserlib.R_Generic):
class R_2_groups_name(baserlib.R_Generic):
"""/2/groups/[group_name] resources.
"""/2/groups/[group_name] resource.
"""
def GET(self):
......@@ -670,7 +670,7 @@ def _ParseRenameGroupRequest(name, data, dry_run):
class R_2_groups_name_rename(baserlib.R_Generic):
"""/2/groups/[groupe_name]/rename resource.
"""/2/groups/[group_name]/rename resource.
"""
def PUT(self):
......@@ -686,7 +686,7 @@ class R_2_groups_name_rename(baserlib.R_Generic):
class R_2_groups_name_assign_nodes(baserlib.R_Generic):
"""/2/groups/[groupe_name]/assign-nodes resource.
"""/2/groups/[group_name]/assign-nodes resource.
"""
def PUT(self):
......@@ -912,7 +912,7 @@ class R_2_instances(baserlib.R_Generic):
class R_2_instances_name(baserlib.R_Generic):
"""/2/instances/[instance_name] resources.
"""/2/instances/[instance_name] resource.
"""
def GET(self):
......@@ -1319,7 +1319,7 @@ class R_2_instances_name_modify(baserlib.R_Generic):
class R_2_instances_name_disk_grow(baserlib.R_Generic):
"""/2/instances/[instance_name]/disk/[index]/grow resource.
"""/2/instances/[instance_name]/disk/[disk_index]/grow resource.
"""
def POST(self):
......@@ -1420,7 +1420,7 @@ class R_2_nodes_name_tags(_R_Tags):
class R_2_tags(_R_Tags):
""" /2/instances/tags resource.
""" /2/tags resource.
Manages cluster tags.
......
......@@ -72,7 +72,12 @@ class TestDocs(unittest.TestCase):
msg=("Missing documentation for hook %s/%s" %
(lucls.HTYPE, lucls.HPATH)))
def _CheckRapiResource(self, uri, fixup):
def _CheckRapiResource(self, uri, fixup, handler):
docline = "%s resource." % uri
self.assertEqual(handler.__doc__.splitlines()[0].strip(), docline,
msg=("First line of %r's docstring is not %r" %
(handler, docline)))
# Apply fixes before testing
for (rx, value) in fixup.items():
uri = rx.sub(value, uri)
......@@ -131,7 +136,7 @@ class TestDocs(unittest.TestCase):
if title.startswith("``") and title.endswith("``"):
uri = title[2:-2]
if key.match(uri):
self._CheckRapiResource(uri, uri_check_fixup)
self._CheckRapiResource(uri, uri_check_fixup, handler)
found = True
break
......@@ -144,7 +149,7 @@ class TestDocs(unittest.TestCase):
msg="Path %r does not start with '/2/'" % key)
if ("``%s``" % key) in titles:
self._CheckRapiResource(key, {})
self._CheckRapiResource(key, {}, handler)
else:
undocumented.append(key)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment