QA RAPI: Test HTTP 404 and 501
authorMichael Hanselmann <hansmi@google.com>
Tue, 19 Oct 2010 16:14:00 +0000 (18:14 +0200)
committerMichael Hanselmann <hansmi@google.com>
Wed, 20 Oct 2010 12:05:55 +0000 (14:05 +0200)
This tests the HTTP Not Found and Not Implemented errors.

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

qa/qa_rapi.py

index df01788..a1b371e 100644 (file)
@@ -178,6 +178,24 @@ def TestEmptyCluster():
     ("/2/os", None, 'GET', None),
     ])
 
+  # Test HTTP Not Found
+  for method in ["GET", "PUT", "POST", "DELETE"]:
+    try:
+      _DoTests([("/99/resource/not/here/99", None, method, None)])
+    except rapi.client.GanetiApiError, err:
+      AssertEqual(err.code, 404)
+    else:
+      raise qa_error.Error("Non-existent resource didn't return HTTP 404")
+
+  # Test HTTP Not Implemented
+  for method in ["PUT", "POST", "DELETE"]:
+    try:
+      _DoTests([("/version", None, method, None)])
+    except rapi.client.GanetiApiError, err:
+      AssertEqual(err.code, 501)
+    else:
+      raise qa_error.Error("Non-implemented method didn't fail")
+
 
 def TestInstance(instance):
   """Testing getting instance(s) info via remote API.