aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/openstack/tempest/test_conf_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'functest/tests/unit/openstack/tempest/test_conf_utils.py')
-rw-r--r--functest/tests/unit/openstack/tempest/test_conf_utils.py75
1 files changed, 23 insertions, 52 deletions
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py
index 8988e96a1..91108e10d 100644
--- a/functest/tests/unit/openstack/tempest/test_conf_utils.py
+++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py
@@ -16,67 +16,34 @@ import mock
from functest.opnfv_tests.openstack.tempest import conf_utils
from functest.opnfv_tests.openstack.tempest import tempest
from functest.utils import config
-from snaps.openstack.os_credentials import OSCreds
class OSTempestConfUtilsTesting(unittest.TestCase):
# pylint: disable=too-many-public-methods
- def setUp(self):
- self.os_creds = OSCreds(
- username='user', password='pass',
- auth_url='http://foo.com:5000/v3', project_name='bar')
- @mock.patch('snaps.openstack.utils.deploy_utils.create_project',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_user',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_network',
- return_value=None)
- @mock.patch('snaps.openstack.utils.deploy_utils.create_image',
- return_value=mock.Mock())
+ @mock.Mock('os_client_config.make_shade')
def test_create_res_missing_net_dic(self, *mock_args):
# pylint: disable=unused-argument
- tempest_resources = tempest.TempestResourcesManager(
- os_creds=self.os_creds)
+ tempest_resources = tempest.TempestResourcesManager()
with self.assertRaises(Exception) as context:
tempest_resources.create()
msg = 'Failed to create private network'
self.assertTrue(msg in context.exception)
- @mock.patch('snaps.openstack.utils.deploy_utils.create_project',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_user',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_network',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_image',
- return_value=None)
+ @mock.Mock('os_client_config.make_shade')
def test_create_res_missing_image(self, *mock_args):
# pylint: disable=unused-argument
- tempest_resources = tempest.TempestResourcesManager(
- os_creds=self.os_creds)
+ tempest_resources = tempest.TempestResourcesManager()
with self.assertRaises(Exception) as context:
tempest_resources.create()
msg = 'Failed to create image'
self.assertTrue(msg in context.exception, msg=str(context.exception))
- @mock.patch('snaps.openstack.utils.deploy_utils.create_project',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_user',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_network',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_image',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.keystone_utils.keystone_client')
- @mock.patch('snaps.openstack.utils.keystone_utils.get_project')
- @mock.patch('snaps.openstack.create_flavor.OpenStackFlavor.create',
- return_value=None)
+ @mock.Mock('os_client_config.make_shade')
def test_create_res_missing_flavor(self, *mock_args):
# pylint: disable=unused-argument
- tempest_resources = tempest.TempestResourcesManager(
- os_creds=self.os_creds)
+ tempest_resources = tempest.TempestResourcesManager()
with self.assertRaises(Exception) as context:
tempest_resources.create()
msg = 'Failed to create flavor'
@@ -188,7 +155,7 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
self.assertTrue(mock_get_vid.called)
self.assertTrue(mock_get_did.called)
- def _test_missing_param(self, params, image_id, flavor_id):
+ def _test_missing_param(self, params, image_id, flavor_id, alt=False):
with mock.patch('functest.opnfv_tests.openstack.tempest.'
'conf_utils.ConfigParser.RawConfigParser.'
'set') as mset, \
@@ -202,10 +169,16 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
mock.patch('functest.utils.functest_utils.yaml.safe_load',
return_value={'validation': {'ssh_timeout': 300}}):
os.environ['OS_ENDPOINT_TYPE'] = ''
- conf_utils.configure_tempest_update_params(
- 'test_conf_file', image_id=image_id,
- flavor_id=flavor_id)
- mset.assert_any_call(params[0], params[1], params[2])
+ if not alt:
+ conf_utils.configure_tempest_update_params(
+ 'test_conf_file', image_id=image_id,
+ flavor_id=flavor_id)
+ mset.assert_any_call(params[0], params[1], params[2])
+ else:
+ conf_utils.configure_tempest_update_params(
+ 'test_conf_file', image_alt_id=image_id,
+ flavor_alt_id=flavor_id)
+ mset.assert_any_call(params[0], params[1], params[2])
self.assertTrue(mread.called)
self.assertTrue(mwrite.called)
@@ -214,20 +187,18 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
'test_image_id', None)
def test_upd_missing_image_id_alt(self):
- conf_utils.IMAGE_ID_ALT = 'test_image_id_alt'
- self._test_missing_param(('compute', 'image_ref_alt',
- 'test_image_id_alt'), None, None)
+ self._test_missing_param(
+ ('compute', 'image_ref_alt', 'test_image_id_alt'),
+ 'test_image_id_alt', None, alt=True)
def test_upd_missing_flavor_id(self):
- setattr(config.CONF, 'tempest_use_custom_flavors', 'True')
self._test_missing_param(('compute', 'flavor_ref', 'test_flavor_id'),
None, 'test_flavor_id')
def test_upd_missing_flavor_id_alt(self):
- setattr(config.CONF, 'tempest_use_custom_flavors', 'True')
- conf_utils.FLAVOR_ID_ALT = 'test_flavor_id_alt'
- self._test_missing_param(('compute', 'flavor_ref_alt',
- 'test_flavor_id_alt'), None, None)
+ self._test_missing_param(
+ ('compute', 'flavor_ref_alt', 'test_flavor_id_alt'),
+ None, 'test_flavor_id_alt', alt=True)
def test_verif_missing_conf_file(self):
with mock.patch('functest.opnfv_tests.openstack.tempest.'