Fix typos in RAPI docstrings, add unittest
authorMichael Hanselmann <hansmi@google.com>
Wed, 12 Jan 2011 12:54:02 +0000 (13:54 +0100)
committerMichael Hanselmann <hansmi@google.com>
Wed, 12 Jan 2011 17:54:06 +0000 (18:54 +0100)
This patch fixes a number of typos and standardizes RAPI resource
docstrings. A unittest is added.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/rapi/connector.py
lib/rapi/rlib2.py
test/docs_unittest.py

index ef03525..fceda6d 100644 (file)
@@ -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
index 3ff2988..499f932 100644 (file)
@@ -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.
 
index fbd31a0..87aa26d 100755 (executable)
@@ -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)