diff --git a/lib/rapi/connector.py b/lib/rapi/connector.py index ff61d1460c25b8baa825561973111aab15c02280..d0b18eba34ebf986129d7bec9ce95bca5438c5f9 100644 --- a/lib/rapi/connector.py +++ b/lib/rapi/connector.py @@ -159,6 +159,10 @@ def GetHandlers(node_name_pattern, instance_name_pattern, job_id_pattern): """Returns all supported resources and their handlers. """ + # Important note: New resources should always be added under /2. During a + # discussion in July 2010 it was decided that having per-resource versions + # is more flexible and future-compatible than versioning the whole remote + # API. return { "/": R_root, @@ -213,9 +217,9 @@ def GetHandlers(node_name_pattern, instance_name_pattern, job_id_pattern): rlib2.R_2_instances_name_migrate, "/2/jobs": rlib2.R_2_jobs, - re.compile(r'/2/jobs/(%s)$' % job_id_pattern): + re.compile(r"^/2/jobs/(%s)$" % job_id_pattern): rlib2.R_2_jobs_id, - re.compile(r'/2/jobs/(%s)/wait$' % job_id_pattern): + re.compile(r"^/2/jobs/(%s)/wait$" % job_id_pattern): rlib2.R_2_jobs_id_wait, "/2/tags": rlib2.R_2_tags, diff --git a/test/docs_unittest.py b/test/docs_unittest.py index 95d81a877860c2cdf883a4e9ba7a01d64aba9dfb..03278d36326388f4c5d4bd5b9a768854bdeff310 100755 --- a/test/docs_unittest.py +++ b/test/docs_unittest.py @@ -92,11 +92,16 @@ class TestDocs(unittest.TestCase): prevline = line + prefix_exception = frozenset(["/", "/version", "/2"]) + undocumented = [] for key, handler in resources.iteritems(): # Regex objects if hasattr(key, "match"): + self.assert_(key.pattern.startswith("^/2/"), + msg="Pattern %r does not start with '^/2/'" % key.pattern) + found = False for title in titles: if (title.startswith("``") and @@ -107,10 +112,14 @@ class TestDocs(unittest.TestCase): if not found: # TODO: Find better way of identifying resource - undocumented.append(str(handler)) + undocumented.append(key.pattern) + + else: + self.assert_(key.startswith("/2/") or key in prefix_exception, + msg="Path %r does not start with '/2/'" % key) - elif ("``%s``" % key) not in titles: - undocumented.append(key) + if ("``%s``" % key) not in titles: + undocumented.append(key) self.failIf(undocumented, msg=("Missing RAPI resource documentation for %s" %