Refactor keystone endpoint tests to the proper test class. 81/35681/1
authorspisarski <s.pisarski@cablelabs.com>
Thu, 1 Jun 2017 18:16:50 +0000 (12:16 -0600)
committerspisarski <s.pisarski@cablelabs.com>
Thu, 1 Jun 2017 18:16:50 +0000 (12:16 -0600)
Also added documentation for those three tests.

Change-Id: I38a728ba9e258a821341621978953e0529a0c1a1
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
docs/how-to-use/APITests.rst
snaps/openstack/utils/keystone_utils.py
snaps/openstack/utils/tests/keystone_utils_tests.py

index 599325f..0a96cd3 100644 (file)
@@ -46,6 +46,15 @@ keystone_utils_tests.py - KeystoneUtilsTests
 | test_create_project_minimal      | 2 & 3         | Tests the creation of a project with minimal configuration|
 |                                  |               | settings via the utility functions                        |
 +----------------------------------+---------------+-----------------------------------------------------------+
+| test_get_endpoint_success        | 2 & 3         | Tests to ensure that proper credentials and proper service|
+|                                  |               | type can succeed                                          |
++----------------------------------+---------------+-----------------------------------------------------------+
+| test_get_endpoint_fail_without   | 2 & 3         | Tests to ensure that proper credentials and improper      |
+| _proper_service                  |               | service type cannot succeed                               |
++----------------------------------+---------------+-----------------------------------------------------------+
+| test_get_endpoint_fail_without   | 2 & 3         | Tests to ensure that improper credentials and proper      |
+| _proper_credentials              |               | service type cannot succeed                               |
++----------------------------------+---------------+-----------------------------------------------------------+
 
 create_user_tests.py - CreateUserSuccessTests
 ---------------------------------------------
index 622481c..337bdc2 100644 (file)
@@ -80,9 +80,8 @@ def get_endpoint(os_creds, service_type, endpoint_type='publicURL'):
     :return: the endpoint url
     """
     auth = get_session_auth(os_creds)
-    return keystone_session(os_creds).get_endpoint(auth=auth,
-                                                   service_type=service_type,
-                                                   endpoint_type=endpoint_type)
+    key_session = keystone_session(os_creds)
+    return key_session.get_endpoint(auth=auth, service_type=service_type, endpoint_type=endpoint_type)
 
 
 def get_project(keystone=None, os_creds=None, project_name=None):
index 7bd7f5a..845b20b 100644 (file)
@@ -46,32 +46,6 @@ class KeystoneSmokeTests(OSComponentTestCase):
             keystone = keystone_utils.keystone_client(OSCreds('user', 'pass', 'url', 'project'))
             keystone.users.list()
 
-    def test_get_endpoint_success(self):
-        """
-        Tests to ensure that proper credentials and proper service type can succeed.
-        """
-        endpoint = keystone_utils.get_endpoint(self.os_creds,
-                                               service_type="identity")
-        self.assertIsNotNone(endpoint)
-
-    def test_get_endpoint_fail_without_proper_service(self):
-        """
-        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.
-        """
-        from snaps.openstack.os_credentials import OSCreds
-
-        with self.assertRaises(Exception):
-            keystone_utils.get_endpoint(
-                OSCreds('user', 'pass', 'url', 'project'),
-                service_type="image")
-
 
 class KeystoneUtilsTests(OSComponentTestCase):
     """
@@ -124,3 +98,29 @@ class KeystoneUtilsTests(OSComponentTestCase):
         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.
+        """
+        endpoint = keystone_utils.get_endpoint(self.os_creds,
+                                               service_type="identity")
+        self.assertIsNotNone(endpoint)
+
+    def test_get_endpoint_fail_without_proper_service(self):
+        """
+        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.
+        """
+        from snaps.openstack.os_credentials import OSCreds
+
+        with self.assertRaises(Exception):
+            keystone_utils.get_endpoint(
+                OSCreds('user', 'pass', 'url', 'project'),
+                service_type="image")