[Kimchi-devel] [PATCH V3 3/3] Update test cases to reflect MAC address update changes

Jose Ricardo Ziviani joserz at linux.vnet.ibm.com
Wed May 27 12:36:57 UTC 2015


Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
---
 tests/test_model.py | 17 ++++++++++++++---
 tests/test_rest.py  | 12 +++++++-----
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/tests/test_model.py b/tests/test_model.py
index 88c020e..cd1556c 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -368,12 +368,23 @@ class ModelTests(unittest.TestCase):
                 self.assertEquals("test-network", iface['network'])
 
                 # update vm interface
+                newMacAddr = '54:50:e3:44:8a:af'
                 iface_args = {"network": "default",
-                              "model": "e1000"}
+                              "model": "e1000",
+                              "mac": newMacAddr,
+                              "type": "network"}
                 inst.vmiface_update(vm_name, mac, iface_args)
+                iface = inst.vmiface_lookup(vm_name, newMacAddr)
+                self.assertEquals(newMacAddr, iface['mac'])
+
+                # undo mac address change
+                iface_args = {"network": "default",
+                              "model": "e1000",
+                              "mac": mac,
+                              "type": "network"}
+                inst.vmiface_update(vm_name, newMacAddr, iface_args)
                 iface = inst.vmiface_lookup(vm_name, mac)
-                self.assertEquals("default", iface['network'])
-                self.assertEquals("e1000", iface["model"])
+                self.assertEquals(mac, iface['mac'])
 
     @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
     def test_vm_disk(self):
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 914b602..d917d8f 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -724,13 +724,15 @@ class RestTests(unittest.TestCase):
             self.assertEquals('network', iface['type'])
 
             # update vm interface
-            req = json.dumps({"network": "default", "model": "virtio"})
+            newMacAddr = '54:50:e3:44:8a:af'
+            req = json.dumps({"network": "default", "model": "virtio",
+                             "type": "network", "mac": newMacAddr})
             resp = self.request('/vms/test-vm/ifaces/%s' % iface['mac'],
                                 req, 'PUT')
-            self.assertEquals(200, resp.status)
-            update_iface = json.loads(resp.read())
-            self.assertEquals(u'virtio', update_iface['model'])
-            self.assertEquals('default', update_iface['network'])
+            self.assertEquals(303, resp.status)
+            iface = json.loads(self.request('/vms/test-vm/ifaces/%s' %
+                                            newMacAddr).read())
+            self.assertEquals(newMacAddr, iface['mac'])
 
             # detach network interface from vm
             resp = self.request('/vms/test-vm/ifaces/%s' % iface['mac'],
-- 
1.9.1




More information about the Kimchi-devel mailing list