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

Aline Manera alinefm at linux.vnet.ibm.com
Wed May 20 18:56:38 UTC 2015


test_model.py and test_rest.py are being discontinued.

Update the test_model_network.py and test_mock_network.py instead.
Let me know if you have doubts with the new files.

On 13/05/2015 15:39, Jose Ricardo Ziviani wrote:
> 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 c2ebd88..7add3d4 100644
> --- a/tests/test_rest.py
> +++ b/tests/test_rest.py
> @@ -725,13 +725,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'],




More information about the Kimchi-devel mailing list