aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/utils
diff options
context:
space:
mode:
authorvalentin boucher <valentin.boucher@orange.com>2017-06-13 08:20:56 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-06-13 08:20:56 +0000
commitfb3ef61a03cdf2fb938d771e9d23f6435cff240f (patch)
tree9bf4162fcb7aca8aa40fde7cb58da6e254f49239 /functest/tests/unit/utils
parent7db24e2b6994487d225c150a20f3a91d7bf12588 (diff)
parent58667cba215c2cb999d6bcaf891980bda4325b42 (diff)
Merge "Refactor core VNF class"
Diffstat (limited to 'functest/tests/unit/utils')
-rw-r--r--functest/tests/unit/utils/test_openstack_utils.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/functest/tests/unit/utils/test_openstack_utils.py b/functest/tests/unit/utils/test_openstack_utils.py
index 15b54057..0f06b1e1 100644
--- a/functest/tests/unit/utils/test_openstack_utils.py
+++ b/functest/tests/unit/utils/test_openstack_utils.py
@@ -1835,6 +1835,77 @@ class OSUtilsTesting(unittest.TestCase):
None)
self.assertTrue(mock_logger_error.called)
+ def test_get_or_create_user_for_vnf_get(self):
+ with mock.patch('functest.utils.openstack_utils.'
+ 'get_user_id',
+ return_value='user_id'), \
+ mock.patch('functest.utils.openstack_utils.get_tenant_id',
+ return_value='tenant_id'):
+ self.assertFalse(openstack_utils.
+ get_or_create_user_for_vnf(self.keystone_client,
+ 'my_vnf'))
+
+ def test_get_or_create_user_for_vnf_create(self):
+ with mock.patch('functest.utils.openstack_utils.'
+ 'get_user_id',
+ return_value=None), \
+ mock.patch('functest.utils.openstack_utils.get_tenant_id',
+ return_value='tenant_id'):
+ self.assertTrue(openstack_utils.
+ get_or_create_user_for_vnf(self.keystone_client,
+ 'my_vnf'))
+
+ def test_get_or_create_user_for_vnf_error_get_user_id(self):
+ with mock.patch('functest.utils.openstack_utils.'
+ 'get_user_id',
+ side_effect=Exception):
+ self.assertRaises(Exception)
+
+ def test_get_or_create_user_for_vnf_error_get_tenant_id(self):
+ with mock.patch('functest.utils.openstack_utils.'
+ 'get_user_id',
+ return_value='user_id'), \
+ mock.patch('functest.utils.openstack_utils.get_tenant_id',
+ side_effect='Exception'):
+ self.assertRaises(Exception)
+
+ def test_get_or_create_tenant_for_vnf_get(self):
+ with mock.patch('functest.utils.openstack_utils.'
+ 'get_tenant_id',
+ return_value='tenant_id'):
+ self.assertFalse(
+ openstack_utils.get_or_create_tenant_for_vnf(
+ self.keystone_client, 'tenant_name', 'tenant_description'))
+
+ def test_get_or_create_tenant_for_vnf_create(self):
+ with mock.patch('functest.utils.openstack_utils.get_tenant_id',
+ return_value=None):
+ self.assertTrue(
+ openstack_utils.get_or_create_tenant_for_vnf(
+ self.keystone_client, 'tenant_name', 'tenant_description'))
+
+ def test_get_or_create_tenant_for_vnf_error_get_tenant_id(self):
+ with mock.patch('functest.utils.openstack_utils.'
+ 'get_tenant_id',
+ side_effect=Exception):
+ self.assertRaises(Exception)
+
+ def test_download_and_add_image_on_glance_image_creation_failure(self):
+ with mock.patch('functest.utils.openstack_utils.'
+ 'os.makedirs'), \
+ mock.patch('functest.utils.openstack_utils.'
+ 'ft_utils.download_url',
+ return_value=True), \
+ mock.patch('functest.utils.openstack_utils.'
+ 'create_glance_image',
+ return_value=''):
+ resp = openstack_utils.download_and_add_image_on_glance(
+ self.glance_client,
+ 'image_name',
+ 'http://url',
+ 'data_dir')
+ self.assertEqual(resp, False)
+
if __name__ == "__main__":
logging.disable(logging.CRITICAL)