summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/utils/tests
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-06-28 09:20:13 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-07-05 08:47:29 -0600
commit139af8603aa484c1ba08997f30204fb7be146606 (patch)
treed15a7b71a1a5780e5b4447071a9fb886d38f5d5e /snaps/openstack/utils/tests
parent2a4dc5493763a241c9895652bf1c71ac3ef0e5b3 (diff)
Refactor OSCreds to leverage kwargs instead of named parameters.
JIRA: SNAPS-109 Change-Id: I423ede964cce9fc3b4e5b27f1e8f0dd7603d9ff1 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils/tests')
-rw-r--r--snaps/openstack/utils/tests/glance_utils_tests.py34
-rw-r--r--snaps/openstack/utils/tests/keystone_utils_tests.py26
2 files changed, 38 insertions, 22 deletions
diff --git a/snaps/openstack/utils/tests/glance_utils_tests.py b/snaps/openstack/utils/tests/glance_utils_tests.py
index 5fa585c..85b59ab 100644
--- a/snaps/openstack/utils/tests/glance_utils_tests.py
+++ b/snaps/openstack/utils/tests/glance_utils_tests.py
@@ -50,7 +50,9 @@ class GlanceSmokeTests(OSComponentTestCase):
from snaps.openstack.os_credentials import OSCreds
with self.assertRaises(Exception):
- glance = glance_utils.glance_client(OSCreds('user', 'pass', 'url', 'project'))
+ glance = glance_utils.glance_client(OSCreds(
+ username='user', password='pass', auth_url='url',
+ project_name='project'))
glance_utils.get_image(glance, 'foo')
@@ -61,8 +63,8 @@ class GlanceUtilsTests(OSComponentTestCase):
def setUp(self):
"""
- Instantiates the CreateImage object that is responsible for downloading and creating an OS image file
- within OpenStack
+ Instantiates the CreateImage object that is responsible for downloading
+ and creating an OS image file within OpenStack
"""
guid = uuid.uuid4()
self.image_name = self.__class__.__name__ + '-' + str(guid)
@@ -89,14 +91,15 @@ class GlanceUtilsTests(OSComponentTestCase):
def test_create_image_minimal_url(self):
"""
- Tests the glance_utils.create_image() function with a URL unless the self.glance_test_meta has configured a
- file to be used.
+ Tests the glance_utils.create_image() function with a URL unless the
+ self.glance_test_meta has configured a file to be used.
"""
if 'disk_file' not in self.glance_test_meta:
- os_image_settings = openstack_tests.cirros_image_settings(name=self.image_name,
- image_metadata=self.glance_test_meta)
+ os_image_settings = openstack_tests.cirros_image_settings(
+ name=self.image_name, image_metadata=self.glance_test_meta)
- self.image = glance_utils.create_image(self.glance, os_image_settings)
+ self.image = glance_utils.create_image(self.glance,
+ os_image_settings)
self.assertIsNotNone(self.image)
self.assertEqual(self.image_name, self.image.name)
@@ -106,21 +109,26 @@ class GlanceUtilsTests(OSComponentTestCase):
validation_utils.objects_equivalent(self.image, image)
else:
- logger.warn('Test not executed as the image metadata requires image files')
+ logger.warn('Test not executed as the image metadata requires '
+ 'image files')
def test_create_image_minimal_file(self):
"""
Tests the glance_utils.create_image() function with a file
"""
if 'disk_file' not in self.glance_test_meta:
- url_image_settings = openstack_tests.cirros_image_settings(name='foo', image_metadata=self.glance_test_meta)
- image_file_name = file_utils.download(url_image_settings.url, self.tmp_dir).name
+ url_image_settings = openstack_tests.cirros_image_settings(
+ name='foo', image_metadata=self.glance_test_meta)
+ image_file_name = file_utils.download(
+ url_image_settings.url, self.tmp_dir).name
else:
image_file_name = self.glance_test_meta['disk_file']
- file_image_settings = openstack_tests.file_image_test_settings(name=self.image_name, file_path=image_file_name)
+ file_image_settings = openstack_tests.file_image_test_settings(
+ name=self.image_name, file_path=image_file_name)
- self.image = glance_utils.create_image(self.glance, file_image_settings)
+ self.image = glance_utils.create_image(self.glance,
+ file_image_settings)
self.assertIsNotNone(self.image)
self.assertEqual(self.image_name, self.image.name)
diff --git a/snaps/openstack/utils/tests/keystone_utils_tests.py b/snaps/openstack/utils/tests/keystone_utils_tests.py
index 845b20b..347b8e0 100644
--- a/snaps/openstack/utils/tests/keystone_utils_tests.py
+++ b/snaps/openstack/utils/tests/keystone_utils_tests.py
@@ -43,7 +43,9 @@ class KeystoneSmokeTests(OSComponentTestCase):
from snaps.openstack.os_credentials import OSCreds
with self.assertRaises(Exception):
- keystone = keystone_utils.keystone_client(OSCreds('user', 'pass', 'url', 'project'))
+ keystone = keystone_utils.keystone_client(OSCreds(
+ username='user', password='pass', auth_url='url',
+ project_name='project'))
keystone.users.list()
@@ -54,8 +56,8 @@ class KeystoneUtilsTests(OSComponentTestCase):
def setUp(self):
"""
- Instantiates the CreateImage object that is responsible for downloading and creating an OS image file
- within OpenStack
+ Instantiates the CreateImage object that is responsible for downloading
+ and creating an OS image file within OpenStack
"""
guid = uuid.uuid4()
self.username = self.__class__.__name__ + '-' + str(guid)
@@ -92,16 +94,19 @@ class KeystoneUtilsTests(OSComponentTestCase):
Tests the keyston_utils.create_project() funtion
"""
project_settings = ProjectSettings(name=self.project_name)
- self.project = keystone_utils.create_project(self.keystone, project_settings)
+ self.project = keystone_utils.create_project(self.keystone,
+ project_settings)
self.assertEqual(self.project_name, self.project.name)
- project = keystone_utils.get_project(keystone=self.keystone, project_name=project_settings.name)
+ project = keystone_utils.get_project(
+ keystone=self.keystone, project_name=project_settings.name)
self.assertIsNotNone(project)
self.assertEqual(self.project_name, self.project.name)
def test_get_endpoint_success(self):
"""
- Tests to ensure that proper credentials and proper service type can succeed.
+ Tests to ensure that proper credentials and proper service type can
+ succeed.
"""
endpoint = keystone_utils.get_endpoint(self.os_creds,
service_type="identity")
@@ -109,18 +114,21 @@ class KeystoneUtilsTests(OSComponentTestCase):
def test_get_endpoint_fail_without_proper_service(self):
"""
- Tests to ensure that proper credentials and improper service type cannot succeed.
+ Tests to ensure that proper credentials and improper service type
+ cannot succeed.
"""
with self.assertRaises(Exception):
keystone_utils.get_endpoint(self.os_creds, service_type="glance")
def test_get_endpoint_fail_without_proper_credentials(self):
"""
- Tests to ensure that improper credentials and proper service type cannot succeed.
+ Tests to ensure that improper credentials and proper service type
+ cannot succeed.
"""
from snaps.openstack.os_credentials import OSCreds
with self.assertRaises(Exception):
keystone_utils.get_endpoint(
- OSCreds('user', 'pass', 'url', 'project'),
+ OSCreds(username='user', password='pass', auth_url='url',
+ project_name='project'),
service_type="image")