[Kimchi-devel] [PATCH 2/3] Kimchi tests: Power system fixes - removing hardcoded values

Aline Manera alinefm at linux.vnet.ibm.com
Fri Mar 20 13:28:23 UTC 2015


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 16/03/2015 16:29, Daniel Henrique Barboza wrote:
> This patch uses the new 'get_template_default' function to remove
> the hardcoded values of memory, disk_bus and nic_model from the
> unit tests to make them compatible with Power systems.
>
> Signed-off-by: Daniel Henrique Barboza <dhbarboza82 at gmail.com>
> ---
>   tests/test_mockmodel.py  | 4 +++-
>   tests/test_rest.py       | 6 ++++--
>   tests/test_vmtemplate.py | 8 ++++++--
>   3 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py
> index 542f845..68a28d3 100644
> --- a/tests/test_mockmodel.py
> +++ b/tests/test_mockmodel.py
> @@ -28,6 +28,7 @@ import kimchi.mockmodel
>   from utils import get_free_port, patch_auth, request, run_server
>   from utils import wait_task
>   from kimchi.control.base import Collection, Resource
> +from kimchi.osinfo import get_template_default
>
>
>   test_server = None
> @@ -158,7 +159,8 @@ class MockModelTests(unittest.TestCase):
>           self.assertEquals(keys, set(info.keys()))
>           self.assertEquals('shutoff', info['state'])
>           self.assertEquals('test-vm', info['name'])
> -        self.assertEquals(1024, info['memory'])
> +        self.assertEquals(get_template_default('old', 'memory'),
> +                          info['memory'])
>           self.assertEquals(1, info['cpus'])
>           self.assertEquals('images/icon-vm.png', info['icon'])
>           self.assertEquals(stats_keys, set(info['stats'].keys()))
> diff --git a/tests/test_rest.py b/tests/test_rest.py
> index d5dd766..4ecf3ce 100644
> --- a/tests/test_rest.py
> +++ b/tests/test_rest.py
> @@ -33,6 +33,7 @@ from functools import partial
>   import iso_gen
>   import kimchi.mockmodel
>   import kimchi.server
> +from kimchi.osinfo import get_template_default
>   from kimchi.rollbackcontext import RollbackContext
>   from kimchi.utils import add_task
>   from utils import fake_auth_header, get_free_port, patch_auth, request
> @@ -730,7 +731,8 @@ class RestTests(unittest.TestCase):
>                                                 iface['mac']).read())
>                   self.assertEquals('default', res['network'])
>                   self.assertEquals(17, len(res['mac']))
> -                self.assertEquals('e1000', res['model'])
> +                self.assertEquals(get_template_default('old', 'nic_model'),
> +                                  res['model'])
>
>               # attach network interface to vm
>               req = json.dumps({"type": "network",
> @@ -957,7 +959,7 @@ class RestTests(unittest.TestCase):
>           self.assertEquals('test', t['name'])
>           self.assertEquals('unknown', t['os_distro'])
>           self.assertEquals('unknown', t['os_version'])
> -        self.assertEquals(1024, t['memory'])
> +        self.assertEquals(get_template_default('old', 'memory'), t['memory'])
>
>           # Deactivate or destroy scan pool return 405
>           resp = self.request('/storagepools/kimchi_isos/storagevolumes'
> diff --git a/tests/test_vmtemplate.py b/tests/test_vmtemplate.py
> index 550bb2a..991cea1 100644
> --- a/tests/test_vmtemplate.py
> +++ b/tests/test_vmtemplate.py
> @@ -22,6 +22,7 @@ import unittest
>   import uuid
>
>
> +from kimchi.osinfo import get_template_default
>   from kimchi.vmtemplate import VMTemplate
>   from kimchi.xmlutils.utils import xpath_get_text
>
> @@ -35,10 +36,13 @@ class VMTemplateTests(unittest.TestCase):
>           os.unlink(self.iso)
>
>       def test_minimal_construct(self):
> +        disk_bus = get_template_default('old', 'disk_bus')
> +        memory = get_template_default('old', 'memory')
> +        nic_model = get_template_default('old', 'nic_model')
>           fields = (('name', 'test'), ('os_distro', 'unknown'),
>                     ('os_version', 'unknown'), ('cpus', 1),
> -                  ('memory', 1024), ('networks', ['default']),
> -                  ('disk_bus', 'ide'), ('nic_model', 'e1000'),
> +                  ('memory', memory), ('networks', ['default']),
> +                  ('disk_bus', disk_bus), ('nic_model', nic_model),
>                     ('graphics', {'type': 'vnc', 'listen': '127.0.0.1'}),
>                     ('cdrom', self.iso))
>




More information about the Kimchi-devel mailing list