[Kimchi-devel] [PATCH V3 4/4] vmiface update support: update test case

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Tue Apr 29 16:37:57 UTC 2014


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

update test_model.py and test_rest.py

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 tests/test_model.py | 10 ++++++++++
 tests/test_rest.py  |  8 ++++++++
 2 files changed, 18 insertions(+)

diff --git a/tests/test_model.py b/tests/test_model.py
index 05e5741..e860df1 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -149,6 +149,8 @@ class ModelTests(unittest.TestCase):
                         'subnet': '127.0.100.0/24'}
             inst.networks_create(net_args)
             rollback.prependDefer(inst.network_delete, net_name)
+            inst.network_activate(net_name)
+            rollback.prependDefer(inst.network_deactivate, net_name)
 
             ifaces = inst.vmifaces_get_list('kimchi-ifaces')
             self.assertEquals(1, len(ifaces))
@@ -172,6 +174,14 @@ class ModelTests(unittest.TestCase):
             self.assertEquals("test-network", iface['network'])
             self.assertEquals("virtio", iface["model"])
 
+            # update vm interface
+            iface_args = {"network": "default",
+                          "model": "e1000"}
+            inst.vmiface_update('kimchi-ifaces', mac, iface_args)
+            iface = inst.vmiface_lookup('kimchi-ifaces', mac)
+            self.assertEquals("default", iface['network'])
+            self.assertEquals("e1000", iface["model"])
+
     @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
     def test_vm_cdrom(self):
         inst = model.Model(objstore_loc=self.tmp_store)
diff --git a/tests/test_rest.py b/tests/test_rest.py
index a260785..26e07c5 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -545,6 +545,14 @@ class RestTests(unittest.TestCase):
             self.assertEquals('virtio', iface['model'])
             self.assertEquals('network', iface['type'])
 
+            # update vm interface
+            req = json.dumps({"network": "default", "model": "e1000"})
+            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('e1000', update_iface['model'])
+            self.assertEquals('default', update_iface['network'])
+
             # detach network interface from vm
             resp = self.request('/vms/test-vm/ifaces/%s' % iface['mac'],
                                 '{}', 'DELETE')
-- 
1.9.0




More information about the Kimchi-devel mailing list