summaryrefslogtreecommitdiffstats
path: root/dovetail/tests/unit/utils/test_dovetail_utils.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-11-14 04:42:11 -0500
committerxudan <xudan16@huawei.com>2018-11-23 03:59:56 -0500
commit6e69ce0329437fcc5a4181eb4d70e44a6c2dbaa5 (patch)
treeb1417ba562ccf81afd2a13c7a0df730704c19dc4 /dovetail/tests/unit/utils/test_dovetail_utils.py
parent0c49866f76164c912308d7b9d1e5b7ce2dd23d34 (diff)
Integrate k8s test casses
In order to integrate k8s test cases, Dovetail framework should do some refactor and make it more general for k8s test cases as well as ONAP ones. Integrate 2 k8s test cases. JIRA: DOVETAIL-748 Change-Id: Ibd87754ffb5fb29f6b4ce79232af860c2ed2da9c Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/tests/unit/utils/test_dovetail_utils.py')
-rw-r--r--dovetail/tests/unit/utils/test_dovetail_utils.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/dovetail/tests/unit/utils/test_dovetail_utils.py b/dovetail/tests/unit/utils/test_dovetail_utils.py
index 60278732..0f0e14f3 100644
--- a/dovetail/tests/unit/utils/test_dovetail_utils.py
+++ b/dovetail/tests/unit/utils/test_dovetail_utils.py
@@ -225,9 +225,10 @@ class DovetailUtilsTesting(unittest.TestCase):
dovetail_utils.dt_cfg.dovetail_config = {'config_dir': file_path}
mock_path.join.return_value = file_complete_name
mock_path.isfile.return_value = False
+ logger = Mock()
expected = ''
- result = dovetail_utils.get_hosts_info(file_path)
+ result = dovetail_utils.get_hosts_info(logger)
mock_path.join.assert_called_once_with(file_path, 'hosts.yaml')
mock_path.isfile.assert_called_once_with(file_complete_name)
@@ -1316,3 +1317,41 @@ class DovetailUtilsTesting(unittest.TestCase):
mock_getenv.assert_called_once_with('DEBUG')
mock_bar.assert_called_once_with(1)
mock_exit.assert_called_once_with(1)
+
+ @patch('os.path', autospec=True)
+ def test_get_openstack_info_no_openrc(self, mock_path):
+ logger = Mock()
+ config_dir = 'config_dir'
+ env_file = 'env_file'
+ dovetail_utils.dt_cfg.dovetail_config = {
+ 'config_dir': config_dir, 'env_file': env_file}
+ mock_path.join.side_effect = ['openrc']
+ mock_path.isfile.return_value = False
+ dovetail_utils.get_openstack_info(logger)
+
+ mock_path.join.assert_called_once_with(config_dir, env_file)
+ mock_path.isfile.assert_called_once_with('openrc')
+ logger.error.assert_called_once_with('File openrc does not exist.')
+
+ @patch('dovetail.utils.dovetail_utils.source_env')
+ @patch('dovetail.utils.dovetail_utils.get_hosts_info')
+ @patch('dovetail.utils.dovetail_utils.get_openstack_endpoint')
+ @patch('dovetail.utils.dovetail_utils.get_hardware_info')
+ @patch('os.path', autospec=True)
+ def test_get_openstack_info(self, mock_path, mock_hardware, mock_endpoint,
+ mock_host, mock_env):
+ logger = Mock()
+ config_dir = 'config_dir'
+ env_file = 'env_file'
+ dovetail_utils.dt_cfg.dovetail_config = {
+ 'config_dir': config_dir, 'env_file': env_file}
+ mock_path.join.side_effect = ['openrc']
+ mock_path.isfile.return_value = True
+ dovetail_utils.get_openstack_info(logger)
+
+ mock_path.join.assert_called_once_with(config_dir, env_file)
+ mock_path.isfile.assert_called_once_with('openrc')
+ mock_env.assert_called_once()
+ mock_host.assert_called_once()
+ mock_endpoint.assert_called_once()
+ mock_hardware.assert_called_once()