3 ##############################################################################
4 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Unittest for yardstick.common.openstack_utils
14 from __future__ import absolute_import
18 from yardstick.common import openstack_utils
21 class GetCredentialsTestCase(unittest.TestCase):
23 @mock.patch('yardstick.common.openstack_utils.os')
24 def test_get_credentials(self, mock_os):
25 mock_os.getenv.return_value = ('2')
26 openstack_utils.get_credentials()
29 class GetHeatApiVersionTestCase(unittest.TestCase):
31 @mock.patch('yardstick.common.openstack_utils.os')
32 def test_get_heat_api_version(self, mock_os):
33 API = 'HEAT_API_VERSION'
34 openstack_utils.get_heat_api_version()
35 mock_os.getenv.assert_called_with(API)
37 @mock.patch('yardstick.common.openstack_utils.os')
38 def test_get_heat_api_version(self, mock_os):
39 mock_os.getenv.return_value = ('2')
41 api_version = openstack_utils.get_heat_api_version()
42 self.assertEqual(api_version, expected_result)