Merge "Add smoke, components, features and performance test suite for Yatdstick"
[yardstick.git] / tests / unit / common / test_openstack_utils.py
1 #!/usr/bin/env python
2
3 ##############################################################################
4 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
5 #
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 ##############################################################################
11
12 # Unittest for yardstick.common.openstack_utils
13
14 import unittest
15 import mock
16
17 from yardstick.common import openstack_utils
18
19
20 class GetCredentialsTestCase(unittest.TestCase):
21
22     @mock.patch('yardstick.common.openstack_utils.os')
23     def test_get_credentials(self, mock_os):
24         mock_os.getenv.return_value = ('2')
25         openstack_utils.get_credentials()
26
27
28 class GetHeatApiVersionTestCase(unittest.TestCase):
29
30     @mock.patch('yardstick.common.openstack_utils.os')
31     def test_get_heat_api_version(self, mock_os):
32         API = 'HEAT_API_VERSION'
33         openstack_utils.get_heat_api_version()
34         mock_os.getenv.assert_called_with(API)
35
36     @mock.patch('yardstick.common.openstack_utils.os')
37     def test_get_heat_api_version(self, mock_os):
38         mock_os.getenv.return_value = ('2')
39         expected_result = '2'
40         api_version = openstack_utils.get_heat_api_version()
41         self.assertEqual(api_version, expected_result)