Modify test to reflect RAPI operation changes
authorHrvoje Ribicic <riba@google.com>
Wed, 29 Jan 2014 13:04:57 +0000 (14:04 +0100)
committerHrvoje Ribicic <riba@google.com>
Wed, 29 Jan 2014 15:26:49 +0000 (16:26 +0100)
A rlib2 unittest tested for the wrong behaviour, and this patch changes
the inputs and expected values to account for this.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

test/py/ganeti.rapi.rlib2_unittest.py

index cb19811..47a86df 100755 (executable)
@@ -1763,18 +1763,27 @@ class TestInstancesMultiAlloc(unittest.TestCase):
     clfactory = _FakeClientFactory(_FakeClient)
     data = {
       "instances": [{
-        "instance_name": "bar",
+        "name": "bar",
         "mode": "create",
+        "disks": [{"size": 1024}],
+        "disk_template": "plain",
+        "nics": [{}],
         }, {
-        "instance_name": "foo",
+        "name": "foo",
         "mode": "create",
+        "disks": [{"size": 1024}],
+        "disk_template": "drbd",
+        "nics": [{}],
         }],
       }
     handler = _CreateHandler(rlib2.R_2_instances_multi_alloc, [], {}, data,
                              clfactory)
+
     (body, _) = handler.GetPostOpInput()
-    self.assertTrue(compat.all([inst["OP_ID"] == handler.POST_OPCODE.OP_ID
-                                for inst in body["instances"]]))
+
+    self.assertTrue(compat.all(
+      [isinstance(inst, opcodes.OpInstanceCreate) for inst in body["instances"]]
+    ))
 
 
 class TestPermissions(unittest.TestCase):