Use snaps_utils to get credentials in tempest
[functest.git] / functest / tests / unit / openstack / tempest / test_tempest.py
index b8b258b..292eb75 100644 (file)
@@ -5,6 +5,8 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 
+# pylint: disable=missing-docstring
+
 import logging
 import unittest
 
@@ -15,10 +17,16 @@ from functest.opnfv_tests.openstack.tempest import tempest
 from functest.opnfv_tests.openstack.tempest import conf_utils
 from functest.utils.constants import CONST
 
+from snaps.openstack.os_credentials import OSCreds
+
 
 class OSTempestTesting(unittest.TestCase):
 
     def setUp(self):
+        os_creds = OSCreds(
+            username='user', password='pass',
+            auth_url='http://foo.com:5000/v3', project_name='bar')
+
         with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
                         'conf_utils.get_verifier_id',
                         return_value='test_deploy_id'), \
@@ -30,14 +38,14 @@ class OSTempestTesting(unittest.TestCase):
                        return_value='test_verifier_repo_dir'), \
             mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
                        'conf_utils.get_verifier_deployment_dir',
-                       return_value='test_verifier_deploy_dir'):
+                       return_value='test_verifier_deploy_dir'), \
+            mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
+                       'get_credentials',
+                       return_value=os_creds):
             self.tempestcommon = tempest.TempestCommon()
             self.tempestsmoke_serial = tempest.TempestSmokeSerial()
             self.tempestsmoke_parallel = tempest.TempestSmokeParallel()
             self.tempestfull_parallel = tempest.TempestFullParallel()
-            with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
-                            'conf_utils.install_verifier_ext'):
-                self.tempestmultisite = tempest.TempestMultisite()
             self.tempestcustom = tempest.TempestCustom()
             self.tempestdefcore = tempest.TempestDefcore()
 
@@ -75,8 +83,6 @@ class OSTempestTesting(unittest.TestCase):
         self.tempestcommon.MODE = mode
         if self.tempestcommon.MODE == 'smoke':
             testr_mode = "smoke"
-        elif self.tempestcommon.MODE == 'feature_multisite':
-            testr_mode = "'[Kk]ingbird'"
         elif self.tempestcommon.MODE == 'full':
             testr_mode = ""
         else:
@@ -96,9 +102,6 @@ class OSTempestTesting(unittest.TestCase):
     def test_generate_test_list_smoke_mode(self):
         self._test_generate_test_list_mode_default('smoke')
 
-    def test_generate_test_list_feature_multisite_mode(self):
-        self._test_generate_test_list_mode_default('feature_multisite')
-
     def test_generate_test_list_full_mode(self):
         self._test_generate_test_list_mode_default('full')
 
@@ -161,8 +164,19 @@ class OSTempestTesting(unittest.TestCase):
                 'os.path.exists', return_value=False)
     @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs')
     @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
-                'conf_utils.create_tempest_resources', side_effect=Exception)
-    def test_run_create_tempest_resources_ko(self, *args):
+                'TempestResourcesManager.create', side_effect=Exception)
+    def test_run_tempest_create_resources_ko(self, *args):
+        self.assertEqual(self.tempestcommon.run(),
+                         testcase.TestCase.EX_RUN_ERROR)
+
+    @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+                'os.path.exists', return_value=False)
+    @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs')
+    @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+                'TempestResourcesManager.create', return_value={})
+    @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
+                'get_active_compute_cnt', side_effect=Exception)
+    def test_run_get_active_compute_cnt_ko(self, *args):
         self.assertEqual(self.tempestcommon.run(),
                          testcase.TestCase.EX_RUN_ERROR)
 
@@ -170,7 +184,9 @@ class OSTempestTesting(unittest.TestCase):
                 'os.path.exists', return_value=False)
     @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs')
     @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
-                'conf_utils.create_tempest_resources', return_value={})
+                'TempestResourcesManager.create', return_value={})
+    @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
+                'get_active_compute_cnt', return_value=2)
     @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
                 'conf_utils.configure_tempest', side_effect=Exception)
     def test_run_configure_tempest_ko(self, *args):
@@ -181,7 +197,9 @@ class OSTempestTesting(unittest.TestCase):
                 'os.path.exists', return_value=False)
     @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs')
     @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
-                'conf_utils.create_tempest_resources', return_value={})
+                'TempestResourcesManager.create', return_value={})
+    @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
+                'get_active_compute_cnt', return_value=2)
     @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
                 'conf_utils.configure_tempest')
     def _test_run(self, status, *args):